Last active
March 20, 2023 23:22
-
-
Save wlee221/09fb32cf9d42740536466a8733781d94 to your computer and use it in GitHub Desktop.
createCommitStatus example
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
const { status_context, description, state, sha, target_url, owner, repo } = process.env; | |
if (state.length === 0 || !["error", "failure", "pending", "success"].includes(state)) { | |
core.setFailed('"state" input cannot be empty.'); | |
return; | |
} | |
if (!["error", "failure", "pending", "success"].includes(state)) { | |
core.setFailed('"state" must be a string input with possible value of (...).'); | |
return; | |
} | |
if (context.length === 0) { | |
core.setFailed('"context" input cannot be empty.'); | |
return; | |
} | |
if (sha.length === 0) { | |
core.setFailed('"sha" input cannot be empty.'); | |
return; | |
} | |
if (!sha.match(/^[0-9a-z]+$/)) { | |
core.setFailed('"sha" must be an alphanumeric string.'); | |
return; | |
} | |
github.rest.repos.createCommitStatus({ | |
owner, | |
repo, | |
sha, | |
state, | |
context: status_context, | |
description: description.length > 0 ? description : undefined, | |
target_url: target_url.length > 0 ? target_url : undefined, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment