From b08a532da32966a8838b790218bc98a6f30591c0 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Fri, 1 May 2026 14:47:16 -0400 Subject: [PATCH] Polish version notifications and sync changelog canvas (#21) (#25) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reworks the daily version bump workflow to: - Pull merged PR titles via gh CLI instead of raw commit messages - Post a polished, non-technical channel message with a link to the changelog canvas - Prepend the new version entry to the Slack canvas via canvases.edit API so the canvas stays in sync automatically Channel message format: "After-Hours Scheduler has been updated to vXXXX.XX.XX Here's a brief summary of what changed: • ... Click here to read the full changelog" --- .github/workflows/deploy-notify.yml | 97 ++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-notify.yml b/.github/workflows/deploy-notify.yml index af3c4a2..96ab5a5 100644 --- a/.github/workflows/deploy-notify.yml +++ b/.github/workflows/deploy-notify.yml @@ -13,6 +13,8 @@ permissions: jobs: notify: runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 with: @@ -30,53 +32,106 @@ jobs: echo "skip=false" >> "$GITHUB_OUTPUT" fi - - name: Check for changes since last version tag + - name: Collect merged PRs since last version if: steps.dst.outputs.skip != 'true' id: changes run: | LAST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -1) + if [ -z "$LAST_TAG" ]; then - echo "No previous version tag — using full history" - COMMITS=$(git log --oneline --pretty=format:"%s") - else - COMMITS=$(git log "$LAST_TAG"..HEAD --oneline --pretty=format:"%s") + echo "No previous version tag" + echo "has_changes=false" >> "$GITHUB_OUTPUT" + exit 0 fi - if [ -z "$COMMITS" ]; then - echo "No new commits since $LAST_TAG" + LAST_TAG_DATE=$(git log -1 --format=%aI "$LAST_TAG") + PRS=$(gh pr list --state merged --json number,title,mergedAt \ + --jq "sort_by(.number) | .[] | select(.mergedAt > \"$LAST_TAG_DATE\")") + + if [ -z "$PRS" ]; then + echo "No PRs merged since $LAST_TAG" echo "has_changes=false" >> "$GITHUB_OUTPUT" exit 0 fi echo "has_changes=true" >> "$GITHUB_OUTPUT" - # Build bullet list from commit messages, skip merge commits - BULLET_LIST=$(echo "$COMMITS" | grep -v "^Merge" | sed 's/^/• /') - { - echo "bullets<> "$GITHUB_OUTPUT" - - # Date-based version - VERSION="v$(date +%Y.%m.%d)" + VERSION="v$(TZ=America/New_York date +%Y.%m.%d)" echo "version=$VERSION" >> "$GITHUB_OUTPUT" + # Build bullet lists from PR titles + TITLES=$(gh pr list --state merged --json number,title,mergedAt \ + --jq "sort_by(.number) | .[] | select(.mergedAt > \"$LAST_TAG_DATE\") | .title") + + { + echo "slack_bullets<> "$GITHUB_OUTPUT" + + { + echo "canvas_bullets< \"$LAST_TAG_DATE\") | \"* \(.title) (PR #\(.number))\"" \ + | sed 's/ *(\(#[0-9]*\))\( (PR\)/ \2/; s/) (PR / (PR /' + echo "ENDCANVAS" + } >> "$GITHUB_OUTPUT" + - name: Create version tag - if: steps.dst.outputs.skip != 'true' && steps.changes.outputs.has_changes == 'true' + if: steps.changes.outputs.has_changes == 'true' run: | git tag ${{ steps.changes.outputs.version }} git push origin ${{ steps.changes.outputs.version }} + - name: Update changelog canvas + if: steps.changes.outputs.has_changes == 'true' + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + CANVAS_ID: ${{ secrets.SLACK_CANVAS_ID }} + SECTION_ID: ${{ secrets.SLACK_CANVAS_INTRO_SECTION }} + VERSION: ${{ steps.changes.outputs.version }} + CANVAS_BULLETS: ${{ steps.changes.outputs.canvas_bullets }} + run: | + TODAY=$(TZ=America/New_York date +%Y-%m-%d) + MARKDOWN=$(printf "---\n\n## %s — %s\n\n%s" "$VERSION" "$TODAY" "$CANVAS_BULLETS") + + RESPONSE=$(curl -s -X POST https://slack.com/api/canvases.edit \ + -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$(jq -n \ + --arg canvas_id "$CANVAS_ID" \ + --arg section_id "$SECTION_ID" \ + --arg markdown "$MARKDOWN" \ + '{ + canvas_id: $canvas_id, + changes: [{ + operation: "insert_after", + section_id: $section_id, + document_content: { + type: "markdown", + markdown: $markdown + } + }] + }')") + + echo "$RESPONSE" | jq . + if [ "$(echo "$RESPONSE" | jq -r .ok)" != "true" ]; then + echo "::warning::Canvas update failed: $(echo "$RESPONSE" | jq -r .error)" + fi + - name: Post to Slack - if: steps.dst.outputs.skip != 'true' && steps.changes.outputs.has_changes == 'true' + if: steps.changes.outputs.has_changes == 'true' env: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }} + CANVAS_ID: ${{ secrets.SLACK_CANVAS_ID }} VERSION: ${{ steps.changes.outputs.version }} - BULLETS: ${{ steps.changes.outputs.bullets }} + SLACK_BULLETS: ${{ steps.changes.outputs.slack_bullets }} run: | - TEXT=$(printf ":rocket: *%s deployed*\n\n%s" "$VERSION" "$BULLETS") + CANVAS_URL="https://app.slack.com/docs/F0B13V3EBUN" + TEXT=$(printf "*After-Hours Scheduler has been updated to %s*\n\nHere's a brief summary of what changed:\n%s\n\n<%s|Click here to read the full changelog>" \ + "$VERSION" "$SLACK_BULLETS" "$CANVAS_URL") + curl -s -X POST https://slack.com/api/chat.postMessage \ -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ -H "Content-Type: application/json" \