Skip to content

Commit

Permalink
Merge pull request #14 from hrvey/feature/status-rollup
Browse files Browse the repository at this point in the history
Switch to using the StatusRollUp field in the graphql API
  • Loading branch information
martingjaldbaek authored Sep 12, 2022
2 parents 0ef9821 + cfb7f02 commit f0870b5
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions combine-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,31 @@ jobs:
let statusOK = true;
if(${{ github.event.inputs.mustBeGreen }}) {
console.log('Checking green status: ' + branch);
const statusResponse = await github.rest.repos.getCombinedStatusForRef({
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number:$pull_number) {
commits(last: 1) {
nodes {
commit {
statusCheckRollup {
state
}
}
}
}
}
}
}`
const vars = {
owner: context.repo.owner,
repo: context.repo.repo,
ref: branch
});
const state = statusResponse['data']['state'];
pull_number: pull['number']
};
const result = await github.graphql(stateQuery, vars);
const [{ commit }] = result.repository.pullRequest.commits.nodes;
const state = commit.statusCheckRollup.state
console.log('Validating status: ' + state);
if(state != 'success') {
if(state != 'SUCCESS') {
console.log('Discarding ' + branch + ' with status ' + state);
statusOK = false;
}
Expand Down

0 comments on commit f0870b5

Please sign in to comment.