1919
2020jobs :
2121 check-concurrent :
22+ name : Deploy Review App to Control Plane / check-concurrent
2223 runs-on : ubuntu-latest
2324 outputs :
2425 cancelled : ${{ steps.check.outputs.cancelled }}
@@ -55,35 +56,34 @@ jobs:
5556
5657 steps :
5758 - name : Create initial comment and get job URL
58- id : init
59+ id : create-comment
5960 uses : actions/github-script@v7
6061 with :
6162 script : |
62- // Get the job ID from the Actions API
63- const { data: jobs } = await github.rest.actions.listJobsForWorkflowRun({
63+ const currentJob = await github.rest.actions.getJobForWorkflowRun({
6464 owner: context.repo.owner,
6565 repo: context.repo.repo,
66- run_id: context.runId,
67- });
68-
69- const currentJob = jobs.jobs.find(job => job.name === context.job);
70- if (!currentJob) {
71- throw new Error('Could not find current job in the workflow run');
72- }
66+ job_id: context.runId
67+ }).then(response => response.data);
7368
7469 const statusUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/job/${currentJob.id}?pr=${context.issue.number || context.payload.pull_request.number}`;
7570 core.exportVariable('statusUrl', statusUrl);
7671
77- const message = "🚀 Starting new deployment for commit: " + context.sha.substring(0, 7) +
72+ const deploymentId = Date.now().toString();
73+ core.exportVariable('deploymentId', deploymentId);
74+
75+ const message = "🚀 Starting new deployment [" + deploymentId + "] for commit: " + context.sha.substring(0, 7) +
7876 "\nChanges: " + (context.payload.commits ? context.payload.commits[0].message : '') +
7977 "\nStatus: " + statusUrl;
8078
81- await github.rest.issues.createComment({
79+ const comment = await github.rest.issues.createComment({
8280 issue_number: context.issue.number || context.payload.pull_request.number,
8381 owner: context.repo.owner,
8482 repo: context.repo.repo,
8583 body: message
8684 });
85+
86+ core.setOutput('comment-id', comment.data.id);
8787
8888 - name : Create GitHub Deployment
8989 id : create-deployment
@@ -146,14 +146,16 @@ jobs:
146146 uses : actions/github-script@v7
147147 env :
148148 RAILS_URL : ${{ steps.deploy.outputs.rails_url }}
149+ COMMENT_ID : ${{ steps.create-comment.outputs.comment-id }}
150+ DEPLOYMENT_ID : ${{ env.deploymentId }}
149151 with :
150152 script : |
151- const message = "✅ Deployment successful!\n\n🚀 Rails app: " + process.env.RAILS_URL + "\n📊 Status: " + process.env.statusUrl;
153+ const message = "✅ Deployment [" + process.env.DEPLOYMENT_ID + "] successful!\n\n🚀 Rails app: " + process.env.RAILS_URL + "\n📊 Status: " + process.env.statusUrl;
152154
153- await github.rest.issues.createComment({
154- issue_number: context.issue.number || context.payload.pull_request.number,
155+ await github.rest.issues.updateComment({
155156 owner: context.repo.owner,
156157 repo: context.repo.repo,
158+ comment_id: process.env.COMMENT_ID,
157159 body: message
158160 });
159161
@@ -169,14 +171,17 @@ jobs:
169171 - name : Post deployment failure
170172 if : failure()
171173 uses : actions/github-script@v7
174+ env :
175+ COMMENT_ID : ${{ steps.create-comment.outputs.comment-id }}
176+ DEPLOYMENT_ID : ${{ env.deploymentId }}
172177 with :
173178 script : |
174- const message = "❌ Deployment failed\n\nCommit: " + context.sha.substring(0, 7) + "\nWorkflow Status: " + process.env.statusUrl;
179+ const message = "❌ Deployment [" + process.env.DEPLOYMENT_ID + "] failed\n\nCommit: " + context.sha.substring(0, 7) + "\nWorkflow Status: " + process.env.statusUrl;
175180
176- await github.rest.issues.createComment({
177- issue_number: context.issue.number || context.payload.pull_request.number,
181+ await github.rest.issues.updateComment({
178182 owner: context.repo.owner,
179183 repo: context.repo.repo,
184+ comment_id: process.env.COMMENT_ID,
180185 body: message
181186 });
182187
0 commit comments