@@ -15,20 +15,44 @@ permissions:
1515 issues : write
1616
1717jobs :
18- deploy :
18+ generate-matrix :
1919 if : |
2020 github.event_name == 'pull_request' &&
21- contains(github.event.pull_request.labels.*.name, 'prerelease')
21+ (contains(github.event.pull_request.labels.*.name, 'prerelease') ||
22+ contains(toJSON(github.event.pull_request.labels.*.name), 'prerelease:'))
23+ runs-on : ubuntu-latest
24+ outputs :
25+ matrix : ${{ steps.set-matrix.outputs.matrix }}
26+ steps :
27+ - name : Checkout code
28+ uses : actions/checkout@v3
29+ - name : Generate matrix from locales config
30+ id : set-matrix
31+ run : |
32+ # Read the locales config and generate matrix for enabled locales
33+ MATRIX=$(jq -c '
34+ to_entries |
35+ map(select(.value.enabled == true)) |
36+ map({
37+ locale: .key,
38+ secret_project_id: .value.secret_project_id
39+ })
40+ ' .github/locales-config.json)
41+ echo "matrix={\"include\":$MATRIX}" >> $GITHUB_OUTPUT
42+ echo "Generated matrix: {\"include\":$MATRIX}"
43+
44+ # Check if there are any enabled locales
45+ ENABLED_COUNT=$(echo "$MATRIX" | jq length)
46+ if [ "$ENABLED_COUNT" -eq 0 ]; then
47+ echo "No enabled locales found in locales-config.json"
48+ exit 1
49+ fi
50+
51+ deploy :
52+ needs : generate-matrix
2253 runs-on : ubuntu-latest
2354 strategy :
24- matrix :
25- include :
26- - locale : en
27- secret_project_id : VERCEL_PROJECT_EN_ID
28- - locale : zh-hans
29- secret_project_id : VERCEL_PROJECT_ZH_HANS_ID
30- - locale : zh-hant
31- secret_project_id : VERCEL_PROJECT_ZH_HANT_ID
55+ matrix : ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
3256 name : Deploy ${{ matrix.locale }}
3357 steps :
3458 # Calculate if this matrix job should run based on PR labels
96120 path : deploy-result.json
97121
98122 comment-vercel-previews :
99- needs : deploy
123+ needs : [generate-matrix, deploy]
100124 name : Comment Vercel Previews
101125 runs-on : ubuntu-latest
102126 steps :
0 commit comments