-
Notifications
You must be signed in to change notification settings - Fork 314
Add chatterbox Slack notifications for failed PR lint runs #6039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 PR lint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| github.event.workflow_run.conclusion == 'failure' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| github.event.workflow_run.event == 'pull_request' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| curl --fail --silent --show-error \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -X POST \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -u "${CHATTERBOX_TOKEN}:" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --data "$message" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data "$message" | |
| printf -v message ':warning: Linter workflow failed for a pull request in %s.\n• Workflow: %s\n• PR: %s\n• Branch: %s\n• Commit: %s\n• Run: %s' "$REPO" "$RUN_NAME" "$PR_URL" "$BRANCH" "$short_sha" "$RUN_URL" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data-binary "$message" |
Copilot
AI
Feb 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In bash, \"\\n\" inside double quotes is not converted to a newline; it becomes a literal backslash+n. This will post \\n sequences rather than multi-line text. Build message using actual newlines (e.g., a heredoc or printf) and consider --data-binary to preserve newline formatting in the request body.
| message=":warning: Linter workflow failed for a pull request in ${REPO}.\n• Workflow: ${RUN_NAME}\n• PR: ${PR_URL}\n• Branch: ${BRANCH}\n• Commit: ${short_sha}\n• Run: ${RUN_URL}" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data "$message" | |
| message="$(cat <<EOF | |
| :warning: Linter workflow failed for a pull request in ${REPO}. | |
| • Workflow: ${RUN_NAME} | |
| • PR: ${PR_URL} | |
| • Branch: ${BRANCH} | |
| • Commit: ${short_sha} | |
| • Run: ${RUN_URL} | |
| EOF | |
| )" | |
| curl --fail --silent --show-error \ | |
| -X POST \ | |
| -u "${CHATTERBOX_TOKEN}:" \ | |
| "${CHATTERBOX_URL%/}/topics/%23api-platform" \ | |
| --data-binary "$message" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ permissions: | |
|
|
||
| on: | ||
| - push | ||
| - pull_request | ||
|
|
||
| jobs: | ||
| lint: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1 @@ | ||||||
| trigger: [this is intentionally broken | ||||||
|
||||||
| trigger: [this is intentionally broken | |
| trigger: ["this is intentionally broken"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
workflow_runpayload’spull_requestsarray can be empty in some cases, which would leavePR_URLblank and degrade the alert. Add a fallback (e.g., link toRUN_URL, or query the PR via the GitHub API usinghead_shawhenpull_requests[0]is missing).