-
Notifications
You must be signed in to change notification settings - Fork 303
58 lines (52 loc) · 2 KB
/
linter-failure-notifier.yml
File metadata and controls
58 lines (52 loc) · 2 KB
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
name: Notify on linter failure
permissions:
contents: read
on:
workflow_run:
workflows:
- Lint OpenAPI Descriptions
types:
- completed
jobs:
notify:
name: Notify #api-platform about failed lint
if: |
github.event.workflow_run.conclusion == 'failure' &&
contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event.workflow_run.event) &&
github.event.workflow_run.repository.full_name == 'github/rest-api-description'
runs-on: ubuntu-latest
steps:
- name: Post failure to chatterbox
env:
CHATTERBOX_URL: ${{ secrets.CHATTERBOX_URL }}
CHATTERBOX_TOKEN: ${{ secrets.CHATTERBOX_TOKEN }}
RUN_URL: ${{ github.event.workflow_run.html_url }}
RUN_NAME: ${{ github.event.workflow_run.name }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
COMMIT: ${{ github.event.workflow_run.head_sha }}
PR_URL: ${{ github.event.workflow_run.pull_requests[0].html_url }}
REPO: ${{ github.event.workflow_run.repository.full_name }}
TRIGGER_EVENT: ${{ github.event.workflow_run.event }}
run: |
if [ -z "$CHATTERBOX_URL" ] || [ -z "$CHATTERBOX_TOKEN" ]; then
echo "CHATTERBOX_URL or CHATTERBOX_TOKEN is not configured; skipping notification."
exit 0
fi
short_sha="${COMMIT:0:7}"
if [ -n "$PR_URL" ]; then
target_line="• PR: ${PR_URL}"
else
target_line="• Trigger: ${TRIGGER_EVENT}"
fi
message=$(printf '%s\n' \
":warning: Linter workflow failed in ${REPO}." \
"• Workflow: ${RUN_NAME}" \
"${target_line}" \
"• Branch: ${BRANCH}" \
"• Commit: ${short_sha}" \
"• Run: ${RUN_URL}")
curl --fail --silent --show-error \
-X POST \
-u "${CHATTERBOX_TOKEN}:" \
"${CHATTERBOX_URL%/}/topics/%23api-platform" \
--data "$message"