diff --git a/.github/workflows/deploy-dev.yaml b/.github/workflows/deploy-dev.yaml index 7aee5e4..05e443a 100644 --- a/.github/workflows/deploy-dev.yaml +++ b/.github/workflows/deploy-dev.yaml @@ -8,6 +8,10 @@ on: - '**.md' - '.gitignore' - 'LICENSE' + workflow_run: + workflows: ["Sync main to dev"] + types: + - completed env: REGISTRY: ghcr.io @@ -16,6 +20,9 @@ env: jobs: build-server: + if: > + github.event_name == 'push' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') uses: ./.github/workflows/build-push-image.yaml permissions: contents: read @@ -24,10 +31,13 @@ jobs: service: server registry: ghcr.io image_name: ${{ github.repository }} - tag: dev-${{ github.sha }} + tag: dev-${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} additional_tag: dev-latest build-worker: + if: > + github.event_name == 'push' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') uses: ./.github/workflows/build-push-image.yaml permissions: contents: read @@ -36,10 +46,13 @@ jobs: service: worker registry: ghcr.io image_name: ${{ github.repository }} - tag: dev-${{ github.sha }} + tag: dev-${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} additional_tag: dev-latest build-tx-indexer: + if: > + github.event_name == 'push' || + (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') uses: ./.github/workflows/build-push-image.yaml permissions: contents: read @@ -48,7 +61,7 @@ jobs: service: tx_indexer registry: ghcr.io image_name: ${{ github.repository }} - tag: dev-${{ github.sha }} + tag: dev-${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} additional_tag: dev-latest deploy: @@ -59,6 +72,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'workflow_run' && 'dev' || github.ref }} - name: Set up kubeconfig run: | @@ -68,7 +83,7 @@ jobs: - name: Update deployment files run: | - TAG="dev-${{ github.sha }}" + TAG="dev-${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}" sed -i "s|image: busybox|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/server:${TAG}|" deploy/01_server.yaml sed -i "s|image: busybox|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/worker:${TAG}|" deploy/01_worker.yaml sed -i "s|image: busybox|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/tx_indexer:${TAG}|" deploy/01_tx_indexer.yaml