55 workflows : ["Merge main into target"]
66 types :
77 - completed
8+ workflow_dispatch :
9+ inputs :
10+ target_branch :
11+ description : ' Target branch to compare against main (default: local)'
12+ required : false
13+ default : ' local'
814
915permissions :
1016 contents : read
1117
1218jobs :
1319 detect-and-build :
14- if : ${{ github.event.workflow_run.conclusion == 'success' }}
20+ if : ${{ ( github.event_name == 'workflow_run' && github. event.workflow_run.conclusion == 'success') || github.event_name == 'workflow_dispatch ' }}
1521 runs-on : ubuntu-latest
1622 steps :
1723 - name : Checkout repository
@@ -20,13 +26,18 @@ jobs:
2026 fetch-depth : 0
2127
2228 - name : Determine target branch
29+ if : ${{ github.event_name != 'workflow_dispatch' }}
2330 run : |
2431 set -euo pipefail
32+ # Prefer a manually-dispatched input, then PR base (if present), then workflow_run.head_branch
2533 if command -v jq >/dev/null 2>&1; then
26- TARGET=$(jq -r '.workflow_run.pull_requests[0].base.ref // .workflow_run.head_branch // empty' "$GITHUB_EVENT_PATH" || true)
34+ TARGET=$(jq -r '.inputs.target_branch // . workflow_run.pull_requests[0].base.ref // .workflow_run.head_branch // empty' "$GITHUB_EVENT_PATH" || true)
2735 else
28- TARGET="${{ github.event.workflow_run.head_branch }}"
36+ # jq not available; leave TARGET empty (jq is available on ubuntu-latest)
37+ TARGET=""
38+ echo "jq not found; TARGET will be empty"
2939 fi
40+
3041 if [ -z "${TARGET:-}" ]; then
3142 echo "TRIGGER_BRANCH=local" >> $GITHUB_ENV
3243 echo "Determined TRIGGER_BRANCH=local"
3647 fi
3748
3849 - name : Detect backend changes between target and main
50+ if : ${{ github.event_name != 'workflow_dispatch' }}
3951 id : detect
4052 run : |
4153 set -euo pipefail
8496 fi
8597
8698 - name : Build and push Docker image
87- if : steps.detect.outputs.backend_changed == 'true'
99+ if : ${{ github.event_name == 'workflow_dispatch' || steps.detect.outputs.backend_changed == 'true' }}
88100 env :
89101 DOCKERHUB_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
90102 DOCKERHUB_TOKEN : ${{ secrets.DOCKERHUB_TOKEN }}
0 commit comments