1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-23 22:04:41 -05:00

update: 修改 docker.yml 镜像构建规则

This commit is contained in:
Nite07 2023-09-15 09:59:21 +08:00
parent 4e7d84499f
commit 1f38125e85

View File

@ -4,6 +4,8 @@ on:
push: push:
branches: branches:
- dev - dev
tags:
- '*'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@ -11,21 +13,51 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out code - name: Check out code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Login to GitHub Container Registry - name: Login to GitHub Container Registry
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image - name: Set tag name
uses: docker/build-push-action@v2 id: set_tag
with: run: |
context: . if [[ $GITHUB_REF == refs/heads/* ]]; then
file: ./Dockerfile echo "::set-output name=tag::$(echo $GITHUB_REF | cut -d'/' -f3)"
push: true else
tags: ghcr.io/${{ github.repository }}:dev echo "::set-output name=tag::${{ github.ref_name }}"
fi
- name: Check if triggered by tag
id: check_tag
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
echo "::set-output name=triggered_by_tag::true"
else
echo "::set-output name=triggered_by_tag::false"
fi
- name: Build and push Docker image for dev branch
if: steps.check_tag.outputs.triggered_by_tag == 'false'
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.tag }}
- name: Build and push Docker image for tags
if: steps.check_tag.outputs.triggered_by_tag == 'true'
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.tag }}
ghcr.io/${{ github.repository }}:latest