Skip to content

Commit d0d1d90

Browse files
committed
workflows: add triage-ci.yml
This will allow us to add automation that will be done after CI failures. For now, we can automate pinging `@woodruffw` and `@alex` on failures of the `brew-pip-audit` workflow to avoid other maintainers from having to manually do this. See related discussions at Homebrew#131661.
1 parent f6177ce commit d0d1d90

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/triage-ci.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Triage CI failure
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- CI
7+
types:
8+
- completed
9+
10+
concurrency:
11+
group: triage-ci-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.id }}
12+
cancel-in-progress: true
13+
14+
env:
15+
HOMEBREW_DEVELOPER: 1
16+
HOMEBREW_NO_AUTO_UPDATE: 1
17+
GH_REPO: ${{ github.repository }}
18+
GH_NO_UPDATE_NOTIFIER: 1
19+
GH_PROMPT_DISABLED: 1
20+
21+
jobs:
22+
status-check:
23+
runs-on: ubuntu-latest
24+
if: >
25+
github.repository_owner == 'Homebrew' &&
26+
github.event.workflow_run.conclusion == 'failure' &&
27+
github.event.workflow_run.event == 'pull_request'
28+
permissions:
29+
contents: read
30+
pull-requests: write
31+
steps:
32+
- name: Download `pull-number` artifact
33+
uses: Homebrew/actions/gh-try-download@master
34+
with:
35+
artifact-name: pull-number
36+
workflow-id: ${{ github.event.workflow_run.id }}
37+
38+
- run: echo "number=$(cat number)" >> "$GITHUB_OUTPUT"
39+
id: pr
40+
41+
- name: Check PR body
42+
id: check
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
PR: ${{ steps.pr.outputs.number }}
46+
run: |
47+
pip_audit="$(
48+
gh api \
49+
--header 'Accept: application/vnd.github+json' \
50+
--header 'X-GitHub-Api-Version: 2022-11-28' \
51+
"repos/{owner}/{repo}/pulls/$PR" \
52+
--jq '.body | contains("brew-pip-audit")'
53+
)"
54+
echo "pip-audit=$pip_audit" >> "$GITHUB_OUTPUT"
55+
56+
- name: Ping `@woodruffw` and `@alex`
57+
if: fromJson(steps.check.outputs.pip-audit)
58+
run: gh pr comment "$PR" --body 'Ping @woodruffw @alex'
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
PR: ${{ steps.pr.outputs.number }}

0 commit comments

Comments
 (0)