@@ -116,6 +116,25 @@ jobs:
116
116
uses : actions/github-script@v7
117
117
with :
118
118
script : |
119
+ async function getWorkflowUrl(runId) {
120
+ // Get the current job ID
121
+ const jobs = await github.rest.actions.listJobsForWorkflowRun({
122
+ owner: context.repo.owner,
123
+ repo: context.repo.repo,
124
+ run_id: runId
125
+ });
126
+
127
+ const currentJob = jobs.data.jobs.find(job => job.status === 'in_progress');
128
+ const jobId = currentJob?.id;
129
+
130
+ if (!jobId) {
131
+ console.log('Warning: Could not find current job ID');
132
+ return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
133
+ }
134
+
135
+ return `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}/job/${jobId}`;
136
+ }
137
+
119
138
// Create initial deployment comment
120
139
const comment = await github.rest.issues.createComment({
121
140
owner: context.repo.owner,
@@ -133,15 +152,20 @@ jobs:
133
152
auto_merge: false,
134
153
required_contexts: []
135
154
});
155
+
156
+ const workflowUrl = await getWorkflowUrl(context.runId);
136
157
137
158
return {
138
159
deploymentId: deployment.data.id,
139
- commentId: comment.data.id
160
+ commentId: comment.data.id,
161
+ workflowUrl
140
162
};
141
163
142
- - name : Set comment ID
164
+ - name : Set comment ID and workflow URL
143
165
if : steps.determine_action.outputs.action == 'deploy'
144
- run : echo "COMMENT_ID=${{ fromJSON(steps.init-deployment.outputs.result).commentId }}" >> $GITHUB_ENV
166
+ run : |
167
+ echo "COMMENT_ID=${{ fromJSON(steps.init-deployment.outputs.result).commentId }}" >> $GITHUB_ENV
168
+ echo "WORKFLOW_URL=${{ fromJSON(steps.init-deployment.outputs.result).workflowUrl }}" >> $GITHUB_ENV
145
169
146
170
- name : Set commit hash
147
171
if : steps.determine_action.outputs.action == 'deploy'
@@ -154,19 +178,16 @@ jobs:
154
178
uses : actions/github-script@v7
155
179
with :
156
180
script : |
157
- const result = ${{ steps.init-deployment.outputs.result }};
158
- const commentId = result.commentId;
159
-
160
181
const buildingMessage = [
161
182
'🏗️ Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
162
183
'',
163
- '[View Build Logs](' + `${ process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${context.job.id}` + ')'
184
+ '[View Build Logs](' + process.env.WORKFLOW_URL + ')'
164
185
].join('\n');
165
186
166
187
await github.rest.issues.updateComment({
167
188
owner: context.repo.owner,
168
189
repo: context.repo.repo,
169
- comment_id: commentId ,
190
+ comment_id: process.env.COMMENT_ID ,
170
191
body: buildingMessage
171
192
});
172
193
@@ -184,21 +205,18 @@ jobs:
184
205
uses : actions/github-script@v7
185
206
with :
186
207
script : |
187
- const result = ${{ steps.init-deployment.outputs.result }};
188
- const commentId = result.commentId;
189
-
190
208
const deployingMessage = [
191
- '🚀 Deploying to Control Plane for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }} ',
209
+ '🚀 Deploying to Control Plane... ',
192
210
'',
193
211
'⏳ Waiting for deployment to be ready...',
194
212
'',
195
- '[View Deploy Logs](' + `${ process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${context.job.id}` + ')'
213
+ '[View Deploy Logs](' + process.env.WORKFLOW_URL + ')'
196
214
].join('\n');
197
215
198
216
await github.rest.issues.updateComment({
199
217
owner: context.repo.owner,
200
218
repo: context.repo.repo,
201
- comment_id: commentId ,
219
+ comment_id: process.env.COMMENT_ID ,
202
220
body: deployingMessage
203
221
});
204
222
@@ -230,7 +248,7 @@ jobs:
230
248
script : |
231
249
const prNumber = process.env.PR_NUMBER;
232
250
const appUrl = process.env.REVIEW_APP_URL;
233
- const workflowUrl = `${ process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${context.job.id}` ;
251
+ const workflowUrl = process.env.WORKFLOW_URL ;
234
252
const isSuccess = '${{ job.status }}' === 'success';
235
253
236
254
// Create GitHub deployment status
0 commit comments