Skip to content

Commit a8e2d73

Browse files
committed
Fix the url of Cirrus failure notifications [ci skip]
The previous one was the url of this notification action, but we want to see a link to Cirrus CI. This code follows https://cirrus-ci.org/guide/notifications/. Also, head_branch was null only for pull requests from a fork, so we can use it for branch-based filtering, which is good.
1 parent c746f38 commit a8e2d73

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

.github/workflows/cirrus-notify.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,33 @@ jobs:
1010
&& github.event.check_suite.conclusion != 'success'
1111
&& github.event.check_suite.conclusion != 'cancelled'
1212
&& github.event.check_suite.conclusion != 'skipped'
13+
&& github.event.check_suite.head_branch == 'master'
1314
runs-on: ubuntu-latest
1415
steps:
16+
- uses: octokit/request-action@v2.x
17+
id: get_failed_check_run
18+
with:
19+
route: GET /repos/${{ github.repository }}/check-suites/${{ github.event.check_suite.id }}/check-runs?status=completed
20+
mediaType: '{"previews": ["antiope"]}'
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1523
- name: Dump GitHub context
1624
env:
1725
GITHUB_CONTEXT: ${{ toJson(github) }}
1826
run: echo "$GITHUB_CONTEXT"
27+
- name: Dump check_runs
28+
env:
29+
CHECK_RUNS: ${{ steps.get_failed_check_run.outputs.data }}
30+
run: echo "$CHECK_RUNS"
1931
- uses: ruby/action-slack@v3.0.0
2032
with:
2133
payload: |
2234
{
2335
"ci": "Cirrus CI",
2436
"env": "Cirrus CI",
25-
"url": "https://github.com/ruby/ruby/actions/runs/${{ github.run_id }}",
37+
"url": "${{ fromJson(steps.get_failed_check_run.outputs.data).check_runs[0].html_url }}",
2638
"commit": "${{ github.event.check_suite.head_commit.id }}",
2739
"branch": "${{ github.event.check_suite.head_branch }}"
2840
}
2941
env:
3042
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
31-
# head_branch can be null. checking it here to see GITHUB_CONTEXT on master.
32-
if: ${{ github.event.check_suite.head_branch == 'master' }}

0 commit comments

Comments
 (0)