From 675890f1553630dccb05e42d5c2f622d28045ae2 Mon Sep 17 00:00:00 2001 From: nite07 Date: Tue, 19 Mar 2024 17:13:04 +0800 Subject: [PATCH] update: github workflow --- .github/workflows/docker-dev.yaml | 48 +++++++++++++++++++++++++++++++ .github/workflows/docker.yaml | 19 +----------- 2 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/docker-dev.yaml diff --git a/.github/workflows/docker-dev.yaml b/.github/workflows/docker-dev.yaml new file mode 100644 index 0000000..2c54bed --- /dev/null +++ b/.github/workflows/docker-dev.yaml @@ -0,0 +1,48 @@ +name: Build and Push Docker + +on: + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ secrets.DOCKER_HUB_USERNAME }}/sub2sing-box + ghcr.io/${{ github.repository }} + tags: dev + + - name: Set up Docker buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image to GHCR and Docker Hub + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + build-args: version=${{ github.sha }} + push: true + platforms: linux/amd64,linux/arm,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index cf204b6..5c315e1 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -2,11 +2,8 @@ name: Build and Push Docker on: push: - branches: - - dev tags: - "*" - workflow_dispatch: jobs: build-and-push: @@ -37,20 +34,6 @@ jobs: ${{ secrets.DOCKER_HUB_USERNAME }}/sub2sing-box ghcr.io/${{ github.repository }} - - name: Prepare args - id: prep - run: | - if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then - VERSION="${{ github.sha }}" - fi - if [[ "$GITHUB_REF" == 'refs/heads/dev' ]]; then - VERSION="${{ github.sha }}" - fi - if [[ "$GITHUB_REF" == 'refs/tags/'* ]]; then - VERSION=$TAG_NAME - fi - echo "version=$VERSION" >> $GITHUB_ENV - - name: Set up Docker buildx uses: docker/setup-buildx-action@v3 @@ -59,7 +42,7 @@ jobs: with: context: . file: ./Dockerfile - build-args: version=${{ env.version }} + build-args: version=${{ github.ref_name }} push: true platforms: linux/amd64,linux/arm,linux/arm64 tags: ${{ steps.meta.outputs.tags }}