Skip to content

Commit 83c686a

Browse files
authored
fix(GHA): branch detection and conditional run (freeCodeCamp#59635)
1 parent f94a944 commit 83c686a

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

.github/workflows/deploy-legacy.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111

1212
jobs:
1313
setup-jobs:
14-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1514
name: Setup Jobs
1615
runs-on: ubuntu-22.04
1716
outputs:
@@ -23,8 +22,22 @@ jobs:
2322
- name: Setup
2423
id: setup
2524
run: |
26-
case "${{ github.ref }}" in
27-
"refs/heads/prod-current")
25+
if [[ "${{ github.event_name }}" == "workflow_run" ]]; then
26+
BRANCH="${{ github.event.workflow_run.head_branch }}"
27+
else
28+
BRANCH="${{ github.ref_name }}"
29+
fi
30+
31+
if [[ "${{ github.event.workflow_run.conclusion }}" != "success" ]]; then
32+
echo "Node.js test run failed. Check logs in its workflow run. Exiting."
33+
exit 1
34+
fi
35+
36+
echo "Node.js test run succeeded. Continuing..."
37+
echo "Current branch: $BRANCH"
38+
39+
case "$BRANCH" in
40+
"prod-current")
2841
echo "site_tld=org" >> $GITHUB_OUTPUT
2942
echo "tgt_env_short=prd" >> $GITHUB_OUTPUT
3043
echo "tgt_env_long=production" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)