@@ -231,43 +231,51 @@ jobs:
231231 org : ${{ env.CPLN_ORG }}
232232 github_token : ${{ secrets.GITHUB_TOKEN }}
233233
234+ - name : Update Status - Success
235+ if : steps.determine_action.outputs.action == 'deploy' && success()
236+ uses : actions/github-script@v7
237+ with :
238+ script : |
239+ const comment = await github.rest.issues.updateComment({
240+ owner: context.repo.owner,
241+ repo: context.repo.repo,
242+ comment_id: steps.init-deployment.outputs.commentId,
243+ body: `🚀 Review App for PR #${process.env.PR_NUMBER}: [\`${process.env.REVIEW_APP_URL}\`](${process.env.REVIEW_APP_URL})`
244+ });
245+
234246 - name : Update Status - Deployment Complete
235247 if : steps.determine_action.outputs.action == 'deploy'
236248 uses : actions/github-script@v7
237249 with :
238250 script : |
251+ const prNumber = process.env.PR_NUMBER;
252+ const appUrl = process.env.REVIEW_APP_URL;
253+ const workflowUrl = steps.init-deployment.outputs.workflowUrl;
239254 const isSuccess = '${{ job.status }}' === 'success';
240255 const result = ${{ steps.init-deployment.outputs.result }};
241256 const deploymentId = result.deploymentId;
242257 const commentId = result.commentId;
243- const workflowUrl = result.workflowUrl;
244- const railsUrl = '${{ steps.deploy.outputs.rails_url }}';
245- const prNumber = process.env.PR_NUMBER;
246258
247259 // Update deployment status
248260 const deploymentStatus = {
249261 owner: context.repo.owner,
250262 repo: context.repo.repo,
251263 deployment_id: deploymentId,
252264 state: isSuccess ? 'success' : 'failure',
253- description: isSuccess ? '✅ Deployment successful' : '❌ Deployment failed'
265+ environment_url: isSuccess ? appUrl : undefined,
266+ log_url: workflowUrl,
267+ environment: 'review'
254268 };
255269
256- if (isSuccess) {
257- deploymentStatus.environment_url = railsUrl;
258- }
259-
260270 await github.rest.repos.createDeploymentStatus(deploymentStatus);
261271
262- // Update the initial comment
272+ // Define messages based on deployment status
263273 const successMessage = [
264- '✅ Deployment successful for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
265- '',
266- '🚀 Rails App: [' + railsUrl + '](' + railsUrl + ')',
274+ '✅ Deployment complete for PR #' + prNumber + ', commit ' + '${{ env.COMMIT_HASH }}',
267275 '',
268- '⚡ [Control Plane Console](https://console.cpln.io/console/org/ ' + process.env.CPLN_ORG + '/gvc/ ' + process.env.APP_NAME + '/workload )',
276+ '🚀 Review App for PR #' + prNumber + ': [` ' + appUrl + '`]( ' + appUrl + ')',
269277 '',
270- '[View Completed Action Build and Deploy Logs](' + workflowUrl + ')'
278+ '📋 [View Completed Action Build and Deploy Logs](' + workflowUrl + ')'
271279 ].join('\n');
272280
273281 const failureMessage = [
@@ -276,6 +284,7 @@ jobs:
276284 '[View Workflow Status](' + workflowUrl + ')'
277285 ].join('\n');
278286
287+ // Update the comment with appropriate message
279288 await github.rest.issues.updateComment({
280289 owner: context.repo.owner,
281290 repo: context.repo.repo,
0 commit comments