Skip to content

workflow: Check for integration result comment #12

workflow: Check for integration result comment

workflow: Check for integration result comment #12

name: Check for integration result
on:
issue_comment:
types: [created, edited]
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:')
try {
// reset before applying labels again
await github.rest.issues.removeLabel({
...issue,
name: ['integration-tests: recommended', 'integration-tests: passing', 'integration-tests: failing'],
})
} catch (error) {
// fails if label is not applied
console.log(error)
}
await github.rest.issues.addLabels({
...issue,
labels: [pass ? 'integration-tests: passing' : 'integration-tests: failing'],
})