post-release-status
Post or update a top-level Slack message that tracks the status of all cherry-picked PRs for a release branch.
Configuration
This skill reads environment-specific values from environment variables (see the repo README.md):
SLACK_BOT_TOKEN— Slack bot token withchannels:history,channels:read,chat:write, andchat:updateOAuth scopes.INTERNAL_REPO—owner/repothat holds your release branches and cherry-pick PRs.REPO_DIR— absolute path to your local checkout ofINTERNAL_REPO.RELEASE_SLACK_CHANNEL— Slack channel name (or ID) to post the status in.RELEASE_CHANNELS— space-separated release channels used to derive the channel label from a branch (defaultpreview stable).STATUS_EMOJI_IN_REVIEW/STATUS_EMOJI_MERGED/STATUS_EMOJI_VERIFIED— Slack emoji for each PR status (defaults:large_yellow_square:/:merged:/:verified:).
All git/gh operations run inside INTERNAL_REPO. Run cd "$REPO_DIR" before executing any git or gh commands.
Step 1: Clarify inputs
Before proceeding, ensure you have:
- Release branch: The full release branch name (e.g.
stable_release/v0.YYYY.MM.DD.HH.MM.stable_NN). This can be provided in one of three ways:- The user gives it directly.
- The user gives a cherry-pick PR URL — deduce the branch from the PR's base branch:
gh pr view <PR_NUMBER> --repo "$INTERNAL_REPO" --json baseRefName --jq '.baseRefName' - If neither is provided, ask the user for the release branch or a PR URL.
- Slack channel ID: The Slack channel to post in (defaults to
$RELEASE_SLACK_CHANNEL; a channel ID looks likeC0123456789). If you only have a channel name, resolve it:curl -s -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ "https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=200" | \ jq -r --arg name "$RELEASE_SLACK_CHANNEL" '.channels[] | select(.name == $name) | .id'
Derive the channel (one of $RELEASE_CHANNELS) and version string from the branch name for display.
If $SLACK_BOT_TOKEN is not set, ask the user for it before proceeding.
Step 2: Find cherry-pick PRs
List all PRs targeting the release branch:
gh pr list --repo "$INTERNAL_REPO" --base $BRANCH_NAME --state all --json number,title,url,state --limit 100
Each PR will have:
state:OPENorMERGEDnumber,title,url: for display
Step 3: Look for an existing status message
Search the Slack channel for the most recent message matching this release:
curl -s -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
"https://slack.com/api/conversations.history?channel=<SLACK_CHANNEL_ID>&limit=50" | \
jq '[.messages[] | select(.text | test("<VERSION_OR_BRANCH_PATTERN>"))] | first | {ts, text}'
Use a pattern that matches the release version or branch name in the message text (e.g. the version string from Step 1).
If a matching message is found:
- Save its
tsfor updating later. - Parse the message to find previously tracked PRs and their statuses. Look for these emoji patterns:
$STATUS_EMOJI_IN_REVIEW(default:large_yellow_square:) → in review$STATUS_EMOJI_MERGED(default:merged:) → merged$STATUS_EMOJI_VERIFIED(default:verified:) → verified
- Preserve
$STATUS_EMOJI_VERIFIEDstatus — do not downgrade a verified PR back to merged.
If no matching message is found: proceed with current GitHub state only.
Step 4: Determine final PR statuses
For each cherry-pick PR, determine the display status:
- If the PR was
$STATUS_EMOJI_VERIFIEDin the previous message → keep as$STATUS_EMOJI_VERIFIED - Else if the PR state is
MERGEDon GitHub →$STATUS_EMOJI_MERGED - Else if the PR state is
OPENon GitHub →$STATUS_EMOJI_IN_REVIEW
Step 5: Format the message
Use Slack Block Kit so the release name renders as a true header (larger text). Build a blocks JSON array and a plain-text text fallback (used for notifications and for searching in Step 3):
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "<version> <channel> release"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "• :large_yellow_square: <https://github.com/OWNER/REPO/pull/123|PR #123> — <title>\n• :merged: <https://github.com/OWNER/REPO/pull/456|PR #456> — <title>\n• :verified: <https://github.com/OWNER/REPO/pull/789|PR #789> — <title>"
}
}
]
Also set TEXT_FALLBACK to the plain version of the title (e.g. "v0.YYYY.MM.DD stable release") — this is used for notifications and for the search pattern in Step 3.
Use Slack mrkdwn hyperlink format in the section block: <URL|display text>.
Step 6: Post or update the message
If updating an existing message (message ts found in Step 3):
curl -s -X POST \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json" \
--data "$(jq -n \
--arg channel "<SLACK_CHANNEL_ID>" \
--arg ts "<EXISTING_MESSAGE_TS>" \
--arg text "$TEXT_FALLBACK" \
--argjson blocks "$BLOCKS_JSON" \
'{channel: $channel, ts: $ts, text: $text, blocks: $blocks}')" \
"https://slack.com/api/chat.update" | jq '{ok, ts, error}'
If posting a new message:
curl -s -X POST \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json" \
--data "$(jq -n \
--arg channel "<SLACK_CHANNEL_ID>" \
--arg text "$TEXT_FALLBACK" \
--argjson blocks "$BLOCKS_JSON" \
'{channel: $channel, text: $text, blocks: $blocks}')" \
"https://slack.com/api/chat.postMessage" | jq '{ok, ts, error}'
Step 7: Confirm
Share the permalink with the user:
curl -s -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
"https://slack.com/api/chat.getPermalink?channel=<SLACK_CHANNEL_ID>&message_ts=<MESSAGE_TS>" | \
jq -r '.permalink'
Notes
- The message is always a top-level message, not a thread reply.
- When updating, PR statuses are refreshed from GitHub, but
$STATUS_EMOJI_VERIFIEDstatuses are preserved from the previous message. - If the API returns
ok: false, check theerrorfield. Common errors:not_in_channel,missing_scope,message_not_found. - To manually mark a PR as verified, the user can ask to update a specific PR's status.