summaryrefslogtreecommitdiff
path: root/.github/workflows/duplicates.yml
blob: 54006fec799e50bae45f179796fa898801207c74 (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
47
48
49
50
51
52
53
54
name: duplicates

on:
  schedule:
    - cron: '0 12 * * *'
  push:
    branches: [dev]
  pull_request:
    branches: [dev]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Prepare job
        run: |
          LAST_STATUS=$(gh run list -R ${GITHUB_REPOSITORY} \
            --branch=dev \
            --workflow=duplicates.yml \
            --status=completed \
            --json=event,conclusion \
            --jq='first(.[] | select(.event != "pull_request")).conclusion'
          )
          IRC_NOTIFY=${{ github.repository == 'gentoo/guru' && github.event_name != 'pull_request' }}
          echo "last_status=${LAST_STATUS}" >> "${GITHUB_ENV}"
          echo "irc_notify=${IRC_NOTIFY}" >> "${GITHUB_ENV}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Check out repository
        uses: actions/checkout@v6
        with:
          ref: dev
      - name: Setup master gentoo repository
        run: |
          ./scripts/setup-master-gentoo.sh
      - name: Check for duplicates
        run: |
          ./scripts/check-duplicates.sh
      - name: Inform failure on IRC
        if: ${{ failure() && env.last_status == 'success' && fromJSON(env.irc_notify) }}
        uses: rectalogic/notify-irc@v1
        with:
          channel: "#gentoo-guru"
          server: "irc.libera.chat"
          nickname: "github-ci"
          message: CI failure detected on job ${{ github.workflow }} - ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
      - name: Inform recovery on IRC
        if: ${{ success() && env.last_status != 'success' && fromJSON(env.irc_notify) }}
        uses: rectalogic/notify-irc@v1
        with:
          channel: "#gentoo-guru"
          server: "irc.libera.chat"
          nickname: "github-ci"
          message: CI on job ${{ github.workflow }} is green again. Thanks!