-
Notifications
You must be signed in to change notification settings - Fork 555
49 lines (42 loc) · 1.72 KB
/
check-for-integration-result.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Check for integration result
on:
issue_comment:
types: [created, edited, deleted]
pull_request: # for debugging
jobs:
# fetch comments, if integration-test comment is present, use that to label pass or fail. remove in-progress.
check-for-integration-result:
# if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Get integration result comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
}
const result = await github.rest.issues.listComments(issue);
const integrationComments = result.data.filter(c => c.user.login == 'primer-integration[bot]' && c.body.includes('<!-- test-result'))
if (integrationComments.length === 0) {
console.log('Integration comment with test-result not found')
return
}
const latestComment = integrationComments.pop()
console.log(latestComment.body)
const pass = latestComment.body.includes(':green-circle:')
await github.rest.issues.addLabels({
...issue,
labels: [pass ? 'integration-tests: passing' : 'integration-tests: failing'],
})
try {
await github.rest.issues.removeLabel({
...issue,
name: ['integration-tests: recommended'],
})
} catch (error) {
console.log(error) // no need to fail
}