From c2ec023a068616f25f3ca3e92706abe89af5d9cb Mon Sep 17 00:00:00 2001 From: Patrick Dodgen Date: Wed, 8 Jul 2026 14:09:17 -0600 Subject: [PATCH] feat(slack-deploy-notification): include version + diff since last prod release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds two things to the prod deploy Slack message: 1. The deployed image tag on its own line (previously only in the accessory button) 2. A 'View changes since ' link that opens a GitHub compare view between the previous prod release and the current one The shared workflow is always called with `if: inputs.environment == 'prod'` by every consumer, so no new input is needed. The previous prod release is computed by walking the GH Releases API and picking the most recent non-current, non-draft, non-prerelease entry. Edge cases: - First-ever prod release for a repo → the diff line is omitted gracefully - Same tag deployed twice (rollback / redeploy) → filters self out, picks the next most recent Refs DEVEX-1653. --- .../workflows/slack-deploy-notification.yaml | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slack-deploy-notification.yaml b/.github/workflows/slack-deploy-notification.yaml index c8d4db1..691e5e4 100644 --- a/.github/workflows/slack-deploy-notification.yaml +++ b/.github/workflows/slack-deploy-notification.yaml @@ -28,6 +28,47 @@ jobs: notify: runs-on: ubuntu-latest steps: + # Compute the previous production release tag by walking the GH + # Releases API and picking the most recent non-current, non-draft, + # non-prerelease entry. Callers gate this workflow on + # `inputs.environment == 'prod'`, so filtering out prereleases yields + # the previous prod release specifically. Enables a compare link in + # the Slack message so folks can see exactly what shipped. + - name: Compute previous prod release + diff link + id: diff + env: + GH_TOKEN: ${{ github.token }} + CURRENT_TAG: ${{ inputs.image_tag }} + run: | + set -euo pipefail + PREV_TAG=$(gh release list \ + --repo "${{ github.repository }}" \ + --exclude-drafts \ + --exclude-pre-releases \ + --json tagName,publishedAt \ + --limit 50 \ + | jq -r --arg cur "$CURRENT_TAG" \ + '[.[] | select(.tagName != $cur)] | sort_by(.publishedAt) | reverse | .[0].tagName // ""') + if [ -n "$PREV_TAG" ]; then + COMPARE_URL="${{ github.server_url }}/${{ github.repository }}/compare/${PREV_TAG}...${CURRENT_TAG}" + # Slack mrkdwn: leading tab preserves the indented-bullet style + # used by the other lines in the payload. + DIFF_LINE="\n\t<${COMPARE_URL}|View changes since ${PREV_TAG}>" + echo "Previous prod release: $PREV_TAG" + echo "Compare URL: $COMPARE_URL" + else + # First prod release for this repo — nothing to diff against. + DIFF_LINE="" + echo "No previous prod release found — first-time prod deploy." + fi + { + echo "previous_tag=$PREV_TAG" + echo "diff_line<> "$GITHUB_OUTPUT" + - name: Send deployment notification uses: slackapi/slack-github-action@v1.24.0 env: @@ -42,7 +83,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*${{ github.event.repository.name }} deployed by ${{ github.triggering_actor }}*\n\tView the <${{ inputs.dashboard_url }}|Deployment>\n\tView the <${{ inputs.apm_url }}|Service APM>" + "text": "*${{ github.event.repository.name }} deployed by ${{ github.triggering_actor }}*\n\tVersion: `${{ inputs.image_tag }}`\n\tView the <${{ inputs.dashboard_url }}|Deployment>\n\tView the <${{ inputs.apm_url }}|Service APM>${{ steps.diff.outputs.diff_line }}" }, "accessory": { "type": "button",