summaryrefslogtreecommitdiff
path: root/.github/workflows/cirrus-notify.yml
blob: f6c11a65d3e701b4e11aefd695172966aa094c9f (plain)
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
on:
  check_suite:
    type: ['completed']
name: Cirrus CI failure notification

permissions:
  contents: read

jobs:
  cirrus-notify:
    name: After Cirrus CI Failure
    if: >-
      github.event.check_suite.app.name == 'Cirrus CI'
      && github.event.check_suite.conclusion != 'success'
      && github.event.check_suite.conclusion != 'cancelled'
      && github.event.check_suite.conclusion != 'skipped'
      && github.event.check_suite.head_branch == 'master'
    runs-on: ubuntu-latest
    steps:
      - uses: octokit/request-action@352d2ae93e1805721b5fe308598555ba3bd2c8e2 # v2.1.8
        id: get_failed_check_run
        with:
          route: GET /repos/${{ github.repository }}/check-suites/${{ github.event.check_suite.id }}/check-runs?status=completed
          mediaType: '{"previews": ["antiope"]}'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - name: Dump check_runs
        env:
          CHECK_RUNS: ${{ steps.get_failed_check_run.outputs.data }}
        run: echo "$CHECK_RUNS"
      - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
        with:
          payload: |
            {
              "ci": "Cirrus CI",
              "env": "Cirrus CI",
              "url": "${{ fromJson(steps.get_failed_check_run.outputs.data).check_runs[0].html_url }}",
              "commit": "${{ github.event.check_suite.head_commit.id }}",
              "branch": "${{ github.event.check_suite.head_branch }}"
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot