Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/linter-failure-notifier.yml
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 }}
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow_run payload’s pull_requests array can be empty in some cases, which would leave PR_URL blank and degrade the alert. Add a fallback (e.g., link to RUN_URL, or query the PR via the GitHub API using head_sha when pull_requests[0] is missing).

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Feb 25, 2026

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.

Suggested change
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 uses AI. Check for mistakes.
Copy link

Copilot AI Feb 25, 2026

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.

Suggested change
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"

Copilot uses AI. Check for mistakes.
1 change: 1 addition & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ permissions:

on:
- push
- pull_request

jobs:
lint:
Expand Down
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ Please note that this project is released with a [Contributor Code of Conduct][c

We will gladly accept pull requests for contributions to other files in this repository.

## CI notifications

The `Notify on linter failure` workflow posts failed pull request lint runs to `#api-platform` through chatterbox.

To enable notifications, configure these repository-level Actions secrets:

- `CHATTERBOX_URL`
- `CHATTERBOX_TOKEN`

This workflow is defined in `.github/workflows/linter-failure-notifier.yml`.

### Submitting a pull request

0. [Fork][fork] and clone the repository
Expand Down
1 change: 1 addition & 0 deletions descriptions-next/lint-failure-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
trigger: [this is intentionally broken
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is syntactically invalid YAML and will cause lint/CI to fail continuously once merged (not just during testing). If the goal is to test notifications, consider removing this file before merge, or move it into a test/fixture location that is excluded from the linter inputs (or gate it behind a dedicated test-only workflow).

Suggested change
trigger: [this is intentionally broken
trigger: ["this is intentionally broken"]

Copilot uses AI. Check for mistakes.