From 115eafa5a9723b01677c0c1a55f0c399881c0ca9 Mon Sep 17 00:00:00 2001 From: yourmoonlight Date: Fri, 20 Sep 2024 11:15:39 +0800 Subject: [PATCH] fix mainnet deploy (#2660) --- .github/workflows/deploy_mainnet.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/deploy_mainnet.yml b/.github/workflows/deploy_mainnet.yml index 8d943f18a0..e655e74174 100644 --- a/.github/workflows/deploy_mainnet.yml +++ b/.github/workflows/deploy_mainnet.yml @@ -15,7 +15,47 @@ jobs: deploy-rooch-mainnet: name: Deploy Rooch Mainnet runs-on: self-hosted + if: | + github.event_name == 'workflow_dispatch' || + (github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'release' && + (github.event.release.prerelease == true || github.event.release.prerelease == false)) steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + + - name: Download Docker tag artifact + if: github.event_name == 'workflow_run' + uses: actions/download-artifact@v4 + with: + name: docker_tag + path: . + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GIT_PACKAGE_TOKEN }} + + - name: Determine ref + id: determine-ref + run: | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + echo "REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV + else + if [[ "${{ github.event_name }}" == "workflow_run" ]]; then + echo "REF=$(cat docker_tag.txt)" >> $GITHUB_ENV + else + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + REF=${GITHUB_REF#refs/tags/} + elif [[ "${{ github.ref }}" == refs/heads/* ]]; then + REF=${GITHUB_REF#refs/heads/} + fi + echo "REF=$REF" >> $GITHUB_ENV + fi + fi + + - name: Print ref + run: echo "The Tag Ref is ${{ env.REF }} and The Branch Ref is ${{ github.ref }}" + - name: Deploy to GCP MAINNET VM env: PRIVATE_KEY: ${{ secrets.GCP_MAINNET_SSH_PRIVATE_KEY }}