Skip to content

Commit 7d56103

Browse files
committed
Leverage chcek run instead of workflow run
1 parent 371ab5a commit 7d56103

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

.github/workflows/notify_test_workflow.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ jobs:
3838
with:
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
4040
script: |
41-
const endpoint = 'GET /repos/:owner/:repo/actions/workflows/:id/runs?&branch=:branch'
41+
const endpoint = 'GET /repos/:owner/:repo/commits/:ref/check-runs'
4242
4343
// TODO: Should use pull_request.user and pull_request.user.repos_url?
4444
// If a different person creates a commit to another forked repo,
4545
// it wouldn't be able to detect.
4646
const params = {
4747
owner: context.payload.pull_request.head.repo.owner.login,
4848
repo: context.payload.pull_request.head.repo.name,
49-
id: 'build_and_test.yml',
50-
branch: context.payload.pull_request.head.ref,
49+
ref: context.payload.pull_request.head.ref,
5150
}
5251
5352
console.log('Ref: ' + context.payload.pull_request.head.ref)
@@ -68,7 +67,7 @@ jobs:
6867
const head_sha = context.payload.pull_request.head.sha
6968
let status = 'queued'
7069
71-
if (!runs || runs.data.workflow_runs.length === 0) {
70+
if (!runs || runs.data.check_runs.filter(r => r.name === "Configure jobs").length === 0) {
7271
status = 'completed'
7372
const conclusion = 'action_required'
7473
@@ -100,15 +99,15 @@ jobs:
10099
}
101100
})
102101
} else {
103-
const runID = runs.data.workflow_runs[0].id
102+
const runID = runs.data.check_runs.filter(r => r.name === "Configure jobs")[0].id
104103
105-
if (runs.data.workflow_runs[0].head_sha != context.payload.pull_request.head.sha) {
104+
if (runs.data.check_runs[0].head_sha != context.payload.pull_request.head.sha) {
106105
throw new Error('There was a new unsynced commit pushed. Please retrigger the workflow.');
107106
}
108107
109108
const runUrl = 'https://github.com/'
110109
+ context.payload.pull_request.head.repo.full_name
111-
+ '/actions/runs/'
110+
+ '/runs/'
112111
+ runID
113112
114113
github.checks.create({

0 commit comments

Comments
 (0)