diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 62b851d07..7d0fef034 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,7 +8,7 @@ on: jobs: deploy: - if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: ${{ (github.event_name == 'workflow_dispatch') || (github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'staging')) }} runs-on: blacksmith-2vcpu-ubuntu-2404 environment: ${{ github.event.workflow_run.head_branch }} @@ -16,7 +16,13 @@ jobs: - name: Checkout code uses: actions/checkout@v4 with: - ref: ${{ github.event.workflow_run.head_branch }} + ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || github.event.workflow_run.head_branch }} + + - name: Get commit SHA + id: commit + run: | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Get commit SHA id: commit @@ -80,6 +86,7 @@ jobs: - name: Handle deployment failure if: failure() run: | + echo "## ❌ Deployment Failed!" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "- **Environment:** ${{ github.event.workflow_run.head_branch }}" >> $GITHUB_STEP_SUMMARY