aboutsummaryrefslogtreecommitdiff
blob: bff8c8fecc2b32136b814f8cda36d7e676f88324 (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
55
56
57
58
59
60
61
62
63
---

name: emails

on:
  push:
    branches: [dev]
  pull_request:
    branches: [dev]

jobs:
  bugzilla:
    runs-on: ubuntu-latest
    steps:
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: 3.x

      - name: Checkout repo
        uses: actions/checkout@v3
        with:
          ref: dev
          fetch-depth: 0

      - name: Get compare commit
        run: |
          COMMIT=$(gh run list -R ${GITHUB_REPOSITORY} --branch=dev --workflow=emails.yml --status=success --limit=1 --json=headSha --jq=".[0].headSha")
          echo "last_successful_commit=${COMMIT}" >> "${GITHUB_ENV}"

          if git rev-parse --verify "${COMMIT}^{commit}" > /dev/null; then
            echo -e "\033[92m\u2713 ${COMMIT:0:7} points to a valid commit"
            VALID=true
          else
            echo -e "\033[91m\u2717 ${COMMIT:0:7} doesn't point to a valid commit"
            VALID=false
          fi
          echo "is_commit_valid=${VALID}" >> "${GITHUB_ENV}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Get changed files
        if: ${{ fromJSON(env.is_commit_valid) }}
        uses: tj-actions/changed-files@v37
        with:
          base_sha: ${{ env.last_successful_commit }}
          write_output_files: true
          files: |
            **/metadata.xml

      - name: Check emails against Bugzilla
        if: ${{ fromJSON(env.is_commit_valid) }}
        run: |
          python ./scripts/email-checker.py < .github/outputs/all_changed_files.txt

      - name: Inform on IRC
        if: ${{ failure() && github.repository == 'gentoo/guru' && github.event_name == 'push' }}
        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 }}