Skip to content

fix: don't abort kind-dev-env.sh on macOS when PROM_ENABLED=true #522

fix: don't abort kind-dev-env.sh on macOS when PROM_ENABLED=true

fix: don't abort kind-dev-env.sh on macOS when PROM_ENABLED=true #522

name: Update Release Notes on PR Merge
on:
pull_request_target:
types: [closed]
branches:
- main
jobs:
update-release-notes:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Generate App token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.RELEASE_NOTES_APP_ID }}
private-key: ${{ secrets.RELEASE_NOTES_APP_PRIVATE_KEY }}
- name: Get App user id
id: app-user
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
run: |
echo "user-id=$(gh api "/users/${APP_SLUG}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
- name: Checkout main
uses: actions/checkout@v6
with:
ref: main
token: ${{ steps.app-token.outputs.token }}
- name: Stage release-note fragment and open PR
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
APP_USER_ID: ${{ steps.app-user.outputs.user-id }}
PR_BODY: ${{ github.event.pull_request.body }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_MERGED_AT: ${{ github.event.pull_request.merged_at }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
set -euo pipefail
# Extract the release-note block, collapse to a single line.
# Avoid `xargs` here: with no command it runs `echo` which interprets
# quotes, so notes containing apostrophes (e.g. "Don't ...") would
# error and the fragment would be silently dropped.
NOTE=$(printf '%s' "$PR_BODY" | tr -d '\r' | \
sed -n '/^```release-note/,/^```/p' | sed '1d;$d' | \
tr '\n' ' ' | sed 's/[[:space:]]\+/ /g; s/^ //; s/ $//')
if [[ -z "$NOTE" || "${NOTE,,}" == "none" ]]; then
echo "No valid release note found. Exiting."
exit 0
fi
mkdir -p release-notes.d/unreleased
FRAGMENT="release-notes.d/unreleased/${PR_NUMBER}.md"
{
echo "---"
echo "pr: ${PR_NUMBER}"
echo "url: ${PR_URL}"
echo "author: ${PR_AUTHOR}"
echo "date: ${PR_MERGED_AT:0:10}"
echo "---"
echo "${NOTE}"
} > "$FRAGMENT"
BRANCH="release-notes/pr-${PR_NUMBER}"
git config user.name "${APP_SLUG}[bot]"
git config user.email "${APP_USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add "$FRAGMENT"
git commit -s -m "docs: add release-note fragment for PR #${PR_NUMBER}"
# Force-push so re-runs on the same PR (e.g. after a transient
# token failure) overwrite the existing branch instead of failing
# non-fast-forward.
git push -f origin "$BRANCH"
if gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number' | grep -q .; then
echo "PR already open for $BRANCH; pushed update."
else
gh pr create \
--title "docs: add release-note fragment for PR #${PR_NUMBER}" \
--body "Stages release-note fragment for ${PR_URL}. Will be assembled into RELEASE-NOTES.md at the next release tag." \
--base main \
--head "$BRANCH"
fi