From 8f1ced62ac6422364517d2caa720db3bed88b87b Mon Sep 17 00:00:00 2001 From: keven1024 Date: Sat, 7 Mar 2026 10:57:58 +0800 Subject: [PATCH] chore: refactor publish workflow to separate build and deploy jobs, enhancing clarity and maintainability --- .gitea/workflows/publish.yaml | 130 +++++++++++++++++++++------------- 1 file changed, 79 insertions(+), 51 deletions(-) diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 5583bc5..a62f5a7 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -1,56 +1,84 @@ name: Publish on: - push: - tags: - - '*' + push: + tags: + - '*' jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 - with: - username: fudaoyuanicu - password: ${{ secrets.DOCKER_PASSWORD }} - - uses: docker/metadata-action@v5 - id: meta - with: - images: fudaoyuanicu/015-app - tags: | - type=ref,event=tag - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - - name: Set build time - id: build-time - run: | - echo "time=$(date +%s)" >> $GITHUB_OUTPUT - shell: bash - - name: build-app - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ gitea.ref_name || github.ref_name }} - BUILD_TIME=${{ steps.build-time.outputs.time }} - - name: build-worker - uses: docker/build-push-action@v5 - with: - context: . - file: ./worker/Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Send deployment webhook - run: | - curl -X POST http://192.168.100.5:8364/v1/update \ - -H "Content-Type: application/json" \ - -H "Authorization: Bearer helloworld" + build-app: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: fudaoyuanicu + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: fudaoyuanicu/015-app + tags: | + type=pep440,pattern={{version}} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + - name: Set build time + id: build-time + run: | + echo "time=$(date +%s)" >> $GITHUB_OUTPUT + shell: bash + - name: build-app + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ gitea.ref_name || github.ref_name }} + BUILD_TIME=${{ steps.build-time.outputs.time }} + + build-worker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: fudaoyuanicu + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: fudaoyuanicu/015-worker + tags: | + type=pep440,pattern={{version}} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + - name: Set build time + id: build-time + run: | + echo "time=$(date +%s)" >> $GITHUB_OUTPUT + shell: bash + - name: build-worker + uses: docker/build-push-action@v5 + with: + context: . + file: ./worker/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy: + runs-on: ubuntu-latest + needs: [build-app, build-worker] + steps: + - name: Send deployment webhook + run: | + curl -X POST http://192.168.100.5:8364/v1/update \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer helloworld"