@@ -116,6 +116,25 @@ jobs:
116116 uses : actions/github-script@v7
117117 with :
118118 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+
119138 // Create initial deployment comment
120139 const comment = await github.rest.issues.createComment({
121140 owner: context.repo.owner,
@@ -133,15 +152,20 @@ jobs:
133152 auto_merge: false,
134153 required_contexts: []
135154 });
155+
156+ const workflowUrl = await getWorkflowUrl(context.runId);
136157
137158 return {
138159 deploymentId: deployment.data.id,
139- commentId: comment.data.id
160+ commentId: comment.data.id,
161+ workflowUrl
140162 };
141163
142- - name : Set comment ID
164+ - name : Set comment ID and workflow URL
143165 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
145169
146170 - name : Set commit hash
147171 if : steps.determine_action.outputs.action == 'deploy'
@@ -154,19 +178,16 @@ jobs:
154178 uses : actions/github-script@v7
155179 with :
156180 script : |
157- const result = ${{ steps.init-deployment.outputs.result }};
158- const commentId = result.commentId;
159-
160181 const buildingMessage = [
161182 '🏗️ Building Docker image for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }}',
162183 '',
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 + ')'
164185 ].join('\n');
165186
166187 await github.rest.issues.updateComment({
167188 owner: context.repo.owner,
168189 repo: context.repo.repo,
169- comment_id: commentId ,
190+ comment_id: process.env.COMMENT_ID ,
170191 body: buildingMessage
171192 });
172193
@@ -184,21 +205,18 @@ jobs:
184205 uses : actions/github-script@v7
185206 with :
186207 script : |
187- const result = ${{ steps.init-deployment.outputs.result }};
188- const commentId = result.commentId;
189-
190208 const deployingMessage = [
191- '🚀 Deploying to Control Plane for PR #' + process.env.PR_NUMBER + ', commit ' + '${{ env.COMMIT_HASH }} ',
209+ '🚀 Deploying to Control Plane... ',
192210 '',
193211 '⏳ Waiting for deployment to be ready...',
194212 '',
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 + ')'
196214 ].join('\n');
197215
198216 await github.rest.issues.updateComment({
199217 owner: context.repo.owner,
200218 repo: context.repo.repo,
201- comment_id: commentId ,
219+ comment_id: process.env.COMMENT_ID ,
202220 body: deployingMessage
203221 });
204222
@@ -230,7 +248,7 @@ jobs:
230248 script : |
231249 const prNumber = process.env.PR_NUMBER;
232250 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 ;
234252 const isSuccess = '${{ job.status }}' === 'success';
235253
236254 // Create GitHub deployment status
0 commit comments