diff --git a/.github/workflows/deploy-stg.yml b/.github/workflows/deploy-stg.yml index d1b3c1322..971a09eec 100644 --- a/.github/workflows/deploy-stg.yml +++ b/.github/workflows/deploy-stg.yml @@ -20,6 +20,7 @@ permissions: contents: write issues: write pull-requests: write + statuses: write jobs: getPRHead: @@ -462,20 +463,35 @@ jobs: const successJobs = jobNames.filter((name) => needsObj[name].result === 'success'); let statusMessage; + let status = false; if (failedJobs.length > 0 && cancelledJobs.length > 0) { - statusMessage = `**Staging deployment failed and was cancelled** for commit ${commitHash}\n\n**`; + statusMessage = `**Staging deployment failed and was cancelled** for commit ${commitHash}`; + status = false; } else if (failedJobs.length > 0) { - statusMessage = `**Staging deployment failed** for commit ${commitHash}\n\n**`; + statusMessage = `**Staging deployment failed** for commit ${commitHash}`; + status = false; } else if (cancelledJobs.length > 0) { - statusMessage = `**Staging deployment was cancelled** for commit ${commitHash}\n\n`; + statusMessage = `**Staging deployment was cancelled** for commit ${commitHash}`; + status = false; } else { - statusMessage = `**Staging deployment succeeded** for commit ${commitHash}`; + statusMessage = `**Staging deployment succeeded** for commit ${commitHash}`; + status = true; } + + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: commitHash, + state: status ? 'success' : 'failure', + context: "Successful deployment to staging", + description: status ? undefined : "Successful deployment to staging is required", + }); + await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: parseInt(prId, 10), body: `${statusMessage}\n\n[View run](${runUrl})` }); - \ No newline at end of file +