5252
5353 - name : ' Dispatch if Merged'
5454 if : " steps.pr_status.outputs.STATE == 'MERGED'"
55+ id : ' dispatch_patch'
5556 uses : ' actions/github-script@00f12e3e20659f42342b1c0226afda7f7c042325'
5657 env :
5758 COMMENT_BODY : ' ${{ github.event.comment.body }}'
8283
8384 console.log('Detected channel:', channel);
8485
85- github.rest.actions.createWorkflowDispatch({
86+ const response = await github.rest.actions.createWorkflowDispatch({
8687 owner: context.repo.owner,
8788 repo: context.repo.repo,
8889 workflow_id: 'release-patch-1-create-pr.yml',
9394 dry_run: 'false',
9495 original_pr: '${{ github.event.issue.number }}'
9596 }
96- })
97+ });
98+
99+ // Wait a moment for the workflow to be created, then find it
100+ await new Promise(resolve => setTimeout(resolve, 2000));
101+
102+ const runs = await github.rest.actions.listWorkflowRuns({
103+ owner: context.repo.owner,
104+ repo: context.repo.repo,
105+ workflow_id: 'release-patch-1-create-pr.yml',
106+ per_page: 10
107+ });
108+
109+ // Find the most recent run that matches our trigger
110+ const dispatchedRun = runs.data.workflow_runs.find(run =>
111+ run.event === 'workflow_dispatch' &&
112+ new Date(run.created_at) > new Date(Date.now() - 10000) // Within last 10 seconds
113+ );
114+
115+ if (dispatchedRun) {
116+ core.setOutput('dispatched_run_id', dispatchedRun.id);
117+ core.setOutput('dispatched_run_url', dispatchedRun.html_url);
118+ }
119+
120+ core.setOutput('channel', channel);
97121
98122 - name : ' Comment on Failure'
99123 if : " startsWith(github.event.comment.body, '/patch') && steps.pr_status.outputs.STATE != 'MERGED'"
@@ -102,3 +126,54 @@ jobs:
102126 issue-number : ' ${{ github.event.issue.number }}'
103127 body : |
104128 :x: The `/patch` command failed. This pull request must be merged before a patch can be created.
129+
130+ - name : ' Final Status Comment - Success'
131+ if : " always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && steps.dispatch_patch.outputs.dispatched_run_url"
132+ uses : ' peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
133+ with :
134+ issue-number : ' ${{ github.event.issue.number }}'
135+ body : |
136+ ✅ **Patch workflow dispatched successfully!**
137+
138+ **📋 Details:**
139+ - **Channel**: `${{ steps.dispatch_patch.outputs.channel }}`
140+ - **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
141+
142+ **🔗 Track Progress:**
143+ - [Dispatched patch workflow](${{ steps.dispatch_patch.outputs.dispatched_run_url }})
144+ - [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
145+
146+ - name : ' Final Status Comment - Dispatch Success (No URL)'
147+ if : " always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && !steps.dispatch_patch.outputs.dispatched_run_url"
148+ uses : ' peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
149+ with :
150+ issue-number : ' ${{ github.event.issue.number }}'
151+ body : |
152+ ✅ **Patch workflow dispatched successfully!**
153+
154+ **📋 Details:**
155+ - **Channel**: `${{ steps.dispatch_patch.outputs.channel }}`
156+ - **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
157+
158+ **🔗 Track Progress:**
159+ - [View patch workflows](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
160+ - [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
161+
162+ - name : ' Final Status Comment - Failure'
163+ if : " always() && startsWith(github.event.comment.body, '/patch') && (steps.dispatch_patch.outcome == 'failure' || steps.dispatch_patch.outcome == 'cancelled')"
164+ uses : ' peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d'
165+ with :
166+ issue-number : ' ${{ github.event.issue.number }}'
167+ body : |
168+ ❌ **Patch workflow dispatch failed!**
169+
170+ There was an error dispatching the patch creation workflow.
171+
172+ **🔍 Troubleshooting:**
173+ - Check that the PR is properly merged
174+ - Verify workflow permissions
175+ - Review error logs in the workflow run
176+
177+ **🔗 Debug Links:**
178+ - [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
179+ - [Patch workflow history](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
0 commit comments