generated from im-open/javascript-action-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARCH-2011 - Add teardown step to neutralize the failing status check
- Loading branch information
1 parent
a7d1946
commit 6e993fe
Showing
2 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports = async (github, core, statusCheckId) => { | ||
core.info(`\nUpdate purposely failing status checks: '${statusCheckId}'`); | ||
|
||
if (!statusCheckId || statusCheckId.trim() === '') { | ||
return; | ||
} | ||
|
||
const actualCheck = await github.rest.checks.get({ | ||
owner: 'im-open', | ||
repo: 'process-dotnet-test-results', | ||
check_run_id: statusCheckId | ||
}); | ||
|
||
if (!actualCheck && !actualCheck.data) { | ||
core.setFailed(`Status Check ${statusCheckId} does not appear to exist.`); | ||
} else { | ||
core.info(`Status Check ${statusCheckId} exists.`); | ||
} | ||
|
||
await github.rest.checks | ||
.update({ | ||
owner: 'im-open', | ||
repo: 'process-dotnet-test-results', | ||
check_run_id: statusCheckId, | ||
name: `${actualCheck.name} - UPDATED1`, | ||
conclusion: 'neutral', | ||
output: { | ||
title: `${actualCheck.output.title} - Updated2`, | ||
summary: `${actualCheck.output.summary} - Updated3`, | ||
text: `# Test Update\nThis status check has been modified with a neutral status. It was purposely created with a 'failure' conclusion but we don't want this to prevent the PR from being merged, so it is being changed to neutral.\n${actualCheck.output.text}` | ||
} | ||
}) | ||
.then(() => { | ||
core.info(`The status check '${statusCheckId}' was updated successfully.`); | ||
}) | ||
.catch(error => { | ||
core.info(`An error occurred updating status check '${statusCheckId}'. Error: ${error.message}`); | ||
core.info(`This status check can be ignored when determining whether the PR is ready to merge.`); | ||
}); | ||
}; |