1414 runs-on : ubuntu-latest
1515 permissions :
1616 contents : write
17+ outputs :
18+ # The notify job replies in the start notice's thread.
19+ slack-ts : ${{ steps.slack-start.outputs.ts }}
1720
1821 steps :
1922 - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2326
2427 # Non-fatal: Slack being down must not block the release.
2528 - name : Notify Slack (start)
29+ id : slack-start
2630 if : ${{ vars.SLACK_CHANNEL_ID != '' }}
2731 continue-on-error : true
2832 uses : slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
9397 if : ${{ !cancelled() && vars.SLACK_CHANNEL_ID != '' }}
9498 runs-on : ubuntu-latest
9599
100+ env :
101+ # Notices reply in the start notice's thread, quoted so YAML keeps the ts a
102+ # string. Without a start notice (its post failed or never ran) this is null,
103+ # which the Slack client drops, and they post to the channel. Failures are
104+ # also broadcast to the channel; success stays in the thread.
105+ THREAD_TS : ${{ needs.build.outputs.slack-ts && format('"{0}"', needs.build.outputs.slack-ts) || 'null' }}
106+
96107 steps :
97108 - name : Notify Slack (build failure)
98109 if : ${{ needs.build.result == 'failure' }}
@@ -103,6 +114,8 @@ jobs:
103114 errors : true
104115 payload : |
105116 channel: ${{ vars.SLACK_CHANNEL_ID }}
117+ thread_ts: ${{ env.THREAD_TS }}
118+ reply_broadcast: ${{ env.THREAD_TS != 'null' }}
106119 text: >-
107120 *Codeplain Client*: Build of `${{ github.ref_name }}` FAILED :x:. Nothing was published to PyPI.
108121 See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
@@ -116,6 +129,8 @@ jobs:
116129 errors : true
117130 payload : |
118131 channel: ${{ vars.SLACK_CHANNEL_ID }}
132+ thread_ts: ${{ env.THREAD_TS }}
133+ reply_broadcast: ${{ env.THREAD_TS != 'null' }}
119134 text: >-
120135 *Codeplain Client*: Publishing `${{ github.ref_name }}` to PyPI FAILED :x:.
121136 See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
@@ -141,6 +156,7 @@ jobs:
141156 errors : true
142157 payload : |
143158 channel: ${{ vars.SLACK_CHANNEL_ID }}
159+ thread_ts: ${{ env.THREAD_TS }}
144160 text: >-
145161 *Codeplain Client*: pre-release `${{ github.ref_name }}` published to PyPI :test_tube:.
146162 Normal installs are unaffected — try it with `pip install --pre codeplain==${{ steps.version.outputs.version }}`.
@@ -154,6 +170,7 @@ jobs:
154170 errors : true
155171 payload : |
156172 channel: ${{ vars.SLACK_CHANNEL_ID }}
173+ thread_ts: ${{ env.THREAD_TS }}
157174 text: >-
158175 *Codeplain Client*: `${{ github.ref_name }}` published to PyPI :white_check_mark:.
159176 Install with `pip install --upgrade codeplain`.
@@ -165,7 +182,7 @@ jobs:
165182 # # keeps its minimal permissions and no checkout.
166183 # linear-release:
167184 # name: Record release in Linear
168- # needs: publish-to-pypi
185+ # needs: [build, publish-to-pypi]
169186 # runs-on: ubuntu-latest
170187 #
171188 # permissions:
@@ -192,13 +209,17 @@ jobs:
192209 # # outcome — `failure()` would never fire.
193210 # - name: Notify Slack (release not recorded)
194211 # if: ${{ steps.linear.outcome == 'failure' && vars.SLACK_CHANNEL_ID != '' }}
212+ # env:
213+ # # See the notify job.
214+ # THREAD_TS: ${{ needs.build.outputs.slack-ts && format('"{0}"', needs.build.outputs.slack-ts) || 'null' }}
195215 # uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0
196216 # with:
197217 # method: chat.postMessage
198218 # token: ${{ secrets.SLACK_BOT_TOKEN }}
199219 # errors: true
200220 # payload: |
201221 # channel: ${{ vars.SLACK_CHANNEL_ID }}
222+ # thread_ts: ${{ env.THREAD_TS }}
202223 # text: >-
203224 # *Codeplain Client*: `${{ github.ref_name }}` is on PyPI, but recording it in Linear FAILED :warning:.
204225 # See <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|the run log>.
0 commit comments