Add Slack build notification action#432
Merged
Merged
Conversation
Composite action that sends Slack notifications on build state transitions on main. Detects when a previously-passing workflow starts failing, and when a previously-failing workflow recovers. - Queries GitHub API for previous workflow run conclusions - Skips cancelled runs when determining state transitions - Failure messages include failed job/step names with links - Recovery messages include consecutive failure count and date - Uses Slack Block Kit for structured messages
- Wrap entire script in try/catch, warning on error - Add text fallback to Slack payload for notification previews - Handle empty failure details with informative fallback - Increase job listing page size to 100 for large matrices
- Add github.repository_owner == 'posit-dev' guard so the notification only fires in posit-dev repos - Document the state comparison mismatch between alls-green (build-only) and workflow conclusion (all jobs including clean)
Query the previous run's jobs and compare the CI meta-job's conclusion instead of the workflow-level conclusion. This prevents clean-job flaps from triggering false recovery notifications. Falls back to workflow conclusion if no CI job is found.
Sanitize &, <, > in commit message text before inserting into Slack Block Kit mrkdwn to prevent injection of mentions like <!here> or formatting breakage.
Show at most 5 failed jobs with an "… and N more" summary when there are many failures (e.g. content image matrix). Include total failed job count in the header line.
4ec8104 to
0ecfb96
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new reusable composite GitHub Action to post Slack notifications when CI transitions between passing and failing states, intended for use by image repos’ CI meta-job on main.
Changes:
- Introduces
.github/actions/slack-build-notify/composite action usingactions/github-scriptto compare current vs previous run state. - Sends Slack Block Kit messages for “failure” (with failed job/step details) and “recovery” (with consecutive failure count).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ianpittwood
approved these changes
Apr 9, 2026
Contributor
ianpittwood
left a comment
There was a problem hiding this comment.
LGTM but some of the Copilot feedback may be actionable
Include timed_out and action_required conclusions in the failed job list, not just failure. A timed-out job would otherwise show "No individual job failures identified."
Extract previousConclusion variable so the log message reflects the CI job conclusion when available, matching the value actually used for state transition comparison.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a reusable composite action at
.github/actions/slack-build-notify/that sends Slack notifications on build state transitions onmain:Designed for use in the CI meta-job across product image repos (
images-connect,images-package-manager,images-workbench).Design decisions
actions/github-scriptfor pre-authenticated GitHub API accesscontinue-on-errorin callers so notification issues never block CIposit-dev/repos viagithub.repository_ownerguardtextfallback for notification previewsRequired setup
Each product repo needs a
SLACK_WEBHOOK_URLrepository secret pointing at the#platform-builds-imageschannel webhook.Test plan
SLACK_WEBHOOK_URLsecret to a test repomainand verify Slack message appears