@@ -33,32 +33,41 @@ jobs:
3333 with :
3434 github-token : ${{ secrets.GITHUB_TOKEN }}
3535 script : |
36- const endpoint = " GET /repos/:owner/:repo/pulls?state=:state"
36+ const endpoint = ' GET /repos/:owner/:repo/pulls?state=:state'
3737 const params = {
3838 owner: context.repo.owner,
3939 repo: context.repo.repo,
4040 state: 'open'
4141 }
4242
43- const maybeReady = ["clean", "has_hooks", "unknown", "unstable"];
44- const notReady = ["dirty", " draft" ];
43+ // See https://docs.github.com/en/graphql/reference/enums#mergestatestatus
44+ const maybeReady = ['behind', 'clean', ' draft', 'has_hooks', 'unknown', 'unstable' ];
4545
46+ // Iterate open PRs
4647 for await (const prs of github.paginate.iterator(endpoint,params)) {
48+ // Each page
4749 for await (const pr of prs.data) {
50+ console.log('SHA: ' + pr.head.sha)
51+ console.log(' Mergeable status: ' + pr.mergeable_state)
4852 if (pr.mergeable_state == null || maybeReady.includes(pr.mergeable_state)) {
4953 const checkRuns = await github.request('GET /repos/{owner}/{repo}/commits/{ref}/check-runs', {
5054 owner: context.repo.owner,
5155 repo: context.repo.repo,
5256 ref: pr.head.sha
5357 })
5458
59+ // Iterator GitHub Checks in the PR
5560 for await (const cr of checkRuns.data.check_runs) {
56- if (cr.name == "Build and test") {
57- const params = JSON.parse(cr.output.text) // text contains parameters to make request in JSON
61+ if (cr.name == 'Build and test') {
62+ // text contains parameters to make request in JSON.
63+ const params = JSON.parse(cr.output.text)
64+
65+ // Get the workflow run in the forked repository
5866 const run = await github.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}', params)
5967
6068 // Keep syncing the status of the checks
61- if (run.data.status == "completed") {
69+ if (run.data.status == 'completed') {
70+ console.log(' Run ' + cr.id + ': set status (' + run.data.status + ') and conclusion (' + run.data.conclusion + ')')
6271 const response = await github.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', {
6372 owner: context.repo.owner,
6473 repo: context.repo.repo,
6877 conclusion: run.data.conclusion
6978 })
7079 } else {
80+ console.log(' Run ' + cr.id + ': set status (' + run.data.status + ')')
7181 const response = await github.request('PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}', {
7282 owner: context.repo.owner,
7383 repo: context.repo.repo,
0 commit comments