|
| 1 | +name: Notify Release Pending |
| 2 | +description: > |
| 3 | + Posts the pre-approval job summary and Slack notification. |
| 4 | + Called before the environment gate — reviewer sees this before approving. |
| 5 | +
|
| 6 | +inputs: |
| 7 | + sha: |
| 8 | + description: "Commit SHA being released" |
| 9 | + required: true |
| 10 | + release_tag: |
| 11 | + description: "The release tag (e.g. v0.3.2)" |
| 12 | + required: true |
| 13 | + prev_tag: |
| 14 | + description: "Previous release tag" |
| 15 | + required: false |
| 16 | + default: '' |
| 17 | + branch: |
| 18 | + description: "Branch containing the SHA" |
| 19 | + required: true |
| 20 | + on_main: |
| 21 | + description: "Whether the SHA is on the main branch" |
| 22 | + required: true |
| 23 | + commit_message: |
| 24 | + description: "Commit message at the SHA" |
| 25 | + required: true |
| 26 | + pr_list: |
| 27 | + description: "x1f-delimited PR list from prepare action" |
| 28 | + required: false |
| 29 | + default: '' |
| 30 | + notes: |
| 31 | + description: "Base64-encoded release notes from prepare action" |
| 32 | + required: false |
| 33 | + default: '' |
| 34 | + dry_run: |
| 35 | + description: "Whether this is a dry run" |
| 36 | + required: false |
| 37 | + default: 'false' |
| 38 | + slack_token: |
| 39 | + description: "Slack bot token for posting messages" |
| 40 | + required: true |
| 41 | + slack_channel: |
| 42 | + description: "Slack channel ID to post to" |
| 43 | + required: true |
| 44 | + emoji: |
| 45 | + description: "Emoji prefix for Slack messages" |
| 46 | + required: false |
| 47 | + default: ':package:' |
| 48 | + |
| 49 | +runs: |
| 50 | + using: composite |
| 51 | + steps: |
| 52 | + - name: Post release summary |
| 53 | + shell: bash |
| 54 | + env: |
| 55 | + TAG: ${{ inputs.release_tag }} |
| 56 | + run: | |
| 57 | + NOTES=$(echo "${{ inputs.notes }}" | base64 -d 2>/dev/null) |
| 58 | + if [ -z "$NOTES" ]; then NOTES="_Release notes unavailable._"; fi |
| 59 | +
|
| 60 | + BRANCH_LABEL="[${{ inputs.branch }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/${{ inputs.branch }})" |
| 61 | + if [ "${{ inputs.on_main }}" = "false" ]; then |
| 62 | + BRANCH_LABEL="$BRANCH_LABEL ⚠️" |
| 63 | + fi |
| 64 | +
|
| 65 | + echo "## $GITHUB_REPOSITORY $TAG" >> $GITHUB_STEP_SUMMARY |
| 66 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 67 | +
|
| 68 | + if [ "${{ inputs.dry_run }}" = "true" ]; then |
| 69 | + echo "> [!NOTE]" >> $GITHUB_STEP_SUMMARY |
| 70 | + echo "> Dry run: Nothing will be tagged or published." >> $GITHUB_STEP_SUMMARY |
| 71 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 72 | + fi |
| 73 | +
|
| 74 | + if [ "${{ inputs.on_main }}" = "false" ]; then |
| 75 | + echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY |
| 76 | + echo "> Release SHA is not on main: Is this a special release? (e.g. beta, backport, etc)" >> $GITHUB_STEP_SUMMARY |
| 77 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 78 | + fi |
| 79 | +
|
| 80 | + echo "**SHA:** [${{ inputs.sha }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/commit/${{ inputs.sha }})" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo "**Commit:** ${{ inputs.commit_message }}" >> $GITHUB_STEP_SUMMARY |
| 82 | + echo "**Branch:** $BRANCH_LABEL" >> $GITHUB_STEP_SUMMARY |
| 83 | +
|
| 84 | + if [ -n "${{ inputs.prev_tag }}" ]; then |
| 85 | + DIFF_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/${{ inputs.prev_tag }}...${{ inputs.sha }}" |
| 86 | + echo "**Diff:** [${{ inputs.prev_tag }}...$TAG]($DIFF_URL)" >> $GITHUB_STEP_SUMMARY |
| 87 | + fi |
| 88 | +
|
| 89 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 90 | + echo "$NOTES" >> $GITHUB_STEP_SUMMARY |
| 91 | +
|
| 92 | + - name: Notify Slack |
| 93 | + shell: bash |
| 94 | + env: |
| 95 | + SLACK_BOT_TOKEN: ${{ inputs.slack_token }} |
| 96 | + SLACK_CHANNEL: ${{ inputs.slack_channel }} |
| 97 | + TAG: ${{ inputs.release_tag }} |
| 98 | + APPROVE_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 99 | + run: | |
| 100 | + BRANCH_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/tree/${{ inputs.branch }}" |
| 101 | + BRANCH_LINK="<$BRANCH_URL|${{ inputs.branch }}>" |
| 102 | + if [ "${{ inputs.on_main }}" = "false" ]; then |
| 103 | + BRANCH_INFO="> ⚠️ NOT on main: $BRANCH_LINK" |
| 104 | + else |
| 105 | + BRANCH_INFO="$BRANCH_LINK" |
| 106 | + fi |
| 107 | +
|
| 108 | + DIFF_PART="" |
| 109 | + if [ -n "${{ inputs.prev_tag }}" ]; then |
| 110 | + DIFF_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/${{ inputs.prev_tag }}...${{ inputs.sha }}" |
| 111 | + DIFF_PART=" · <$DIFF_URL|${{ inputs.prev_tag }}...$TAG>" |
| 112 | + fi |
| 113 | +
|
| 114 | + PR_LIST=$(echo "${{ inputs.pr_list }}" | tr $'\x1f' '\n' | sed '/^$/d') |
| 115 | +
|
| 116 | + TEXT="${{ inputs.emoji }} *$GITHUB_REPOSITORY $TAG* awaiting approval" |
| 117 | +
|
| 118 | + if [ "${{ inputs.dry_run }}" = "true" ]; then |
| 119 | + TEXT="$TEXT\n> :information_source: _Dry run: nothing will be tagged or published._" |
| 120 | + fi |
| 121 | +
|
| 122 | + TEXT="$TEXT\n${BRANCH_INFO}${DIFF_PART}" |
| 123 | +
|
| 124 | + if [ -n "$PR_LIST" ]; then |
| 125 | + TEXT="$TEXT\n$PR_LIST" |
| 126 | + fi |
| 127 | +
|
| 128 | + TEXT="$TEXT\n<$APPROVE_URL|View changes & approve>" |
| 129 | +
|
| 130 | + # jq --arg passes strings literally, so \n must be real newlines before encoding |
| 131 | + TEXT=$(printf '%b' "$TEXT") |
| 132 | + curl -s -X POST "https://slack.com/api/chat.postMessage" \ |
| 133 | + -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ |
| 134 | + -H "Content-Type: application/json; charset=utf-8" \ |
| 135 | + -d "$(jq -n --arg channel "$SLACK_CHANNEL" --arg text "$TEXT" \ |
| 136 | + '{channel: $channel, text: $text}')" |
0 commit comments