@@ -14,7 +14,6 @@ permissions:
1414
1515jobs :
1616 deploy :
17- if : contains(github.event.pull_request.labels.*.name, 'prerelease')
1817 runs-on : ubuntu-latest
1918 strategy :
2019 matrix :
@@ -27,13 +26,41 @@ jobs:
2726 secret_project_id : VERCEL_PROJECT_ZH_HANT_ID
2827 name : Deploy ${{ matrix.locale }}
2928 steps :
29+ # Calculate if this matrix job should run based on PR labels
30+ #
31+ # This job will deploy if:
32+ # - The event is NOT a pull_request (e.g., workflow_dispatch)
33+ # - OR the PR has the label 'prerelease'
34+ # - OR the PR has the label 'prerelease:<locale>' matching the current matrix locale
35+ - name : Calculate should_deploy
36+ id : should_deploy
37+ shell : bash
38+ run : |
39+ LABELS_JSON='${{ toJson(github.event.pull_request.labels.*.name) }}'
40+ echo "LABELS_JSON: $LABELS_JSON"
41+ SHOULD_DEPLOY=false
42+ if [[ "${{ github.event_name }}" != "pull_request" ]]; then
43+ SHOULD_DEPLOY=true
44+ elif echo "$LABELS_JSON" | grep -E '"prerelease"' > /dev/null; then
45+ SHOULD_DEPLOY=true
46+ elif echo "$LABELS_JSON" | grep -E '"prerelease:'"${{ matrix.locale }}"'"' > /dev/null; then
47+ SHOULD_DEPLOY=true
48+ fi
49+ echo "should_deploy=$SHOULD_DEPLOY" >> $GITHUB_OUTPUT
3050 - name : Checkout code
51+ if : steps.should_deploy.outputs.should_deploy == 'true'
3152 uses : actions/checkout@v3
3253 with :
3354 fetch-depth : 1
55+ ref : ${{ github.head_ref }}
56+ - name : Log checked out commit
57+ if : steps.should_deploy.outputs.should_deploy == 'true'
58+ run : git log -1
3459 - name : Setup Tools
60+ if : steps.should_deploy.outputs.should_deploy == 'true'
3561 uses : ./.github/actions/setup
3662 - name : Deploy to Vercel (${{ matrix.locale }})
63+ if : steps.should_deploy.outputs.should_deploy == 'true'
3764 id : deploy
3865 uses : ./.github/actions/vercel-deploy
3966 with :
4269 vercel_org_id : ${{ secrets.VERCEL_ORG_ID }}
4370 vercel_token : ${{ secrets.VERCEL_TOKEN }}
4471 - name : Comment PR with Vercel Preview Links (${{ matrix.locale }})
72+ if : steps.should_deploy.outputs.should_deploy == 'true'
4573 uses : ./.github/actions/comment-vercel-preview
4674 with :
4775 inspect_url : ${{ steps.deploy.outputs.inspect_url }}
0 commit comments