Skip to content

Commit 7ec7fb7

Browse files
committed
fix missing channel_id in slack action
1 parent ebafe8b commit 7ec7fb7

7 files changed

Lines changed: 31 additions & 8 deletions

File tree

.github/actions/slack-run-start/action.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ inputs:
1414
outputs:
1515
channel_id:
1616
description: Slack channel id for the posted message.
17-
value: ${{ steps.post.outputs.channel_id }}
17+
value: ${{ steps.extract.outputs.channel_id }}
1818
ts:
1919
description: Slack message timestamp for updates.
20-
value: ${{ steps.post.outputs.ts }}
20+
value: ${{ steps.extract.outputs.ts }}
2121

2222
runs:
2323
using: composite
@@ -38,3 +38,26 @@ runs:
3838
attachments:
3939
- color: "${{ inputs.running_color }}"
4040
text: "${{ inputs.message_prefix }}: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}> started at ${{ steps.start-time.outputs.value }}"
41+
42+
- name: Extract message identifiers
43+
id: extract
44+
shell: bash
45+
env:
46+
SLACK_RESPONSE: ${{ steps.post.outputs.response }}
47+
SLACK_TS: ${{ steps.post.outputs.ts }}
48+
SLACK_CHANNEL_ID: ${{ steps.post.outputs.channel_id }}
49+
run: |
50+
ts="$SLACK_TS"
51+
channel_id="$SLACK_CHANNEL_ID"
52+
53+
if [[ -n "$SLACK_RESPONSE" && "$SLACK_RESPONSE" != "null" ]]; then
54+
if [[ -z "$ts" ]]; then
55+
ts=$(echo "$SLACK_RESPONSE" | jq -r '.ts // empty')
56+
fi
57+
if [[ -z "$channel_id" ]]; then
58+
channel_id=$(echo "$SLACK_RESPONSE" | jq -r '.channel_id // .channel // empty')
59+
fi
60+
fi
61+
62+
echo "ts=$ts" >> "$GITHUB_OUTPUT"
63+
echo "channel_id=$channel_id" >> "$GITHUB_OUTPUT"

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ jobs:
133133
uk.co.bbc.bug.build.commit=${{ github.sha }}
134134
135135
- name: update slack message
136-
if: ${{ always() && steps.slack-start.outputs.ts != '' }}
136+
if: ${{ always() && steps.slack-start.outputs.ts != '' && steps.slack-start.outputs.channel_id != '' }}
137137
uses: ./.github/actions/slack-run-finish
138138
with:
139139
channel_id: ${{ steps.slack-start.outputs.channel_id }}

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143

144144
slack-finish:
145145
name: Slack final status
146-
if: ${{ always() && needs.slack-start.result == 'success' && needs.slack-start.outputs.ts != '' }}
146+
if: ${{ always() && needs.slack-start.result == 'success' && needs.slack-start.outputs.ts != '' && needs.slack-start.outputs.channel_id != '' }}
147147
needs:
148148
- slack-start
149149
- codespell

.github/workflows/test-bug-client.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- run: cd src/client && npm run build --if-present
4949

5050
- name: update slack message
51-
if: ${{ always() && steps.slack-start.outputs.ts != '' }}
51+
if: ${{ always() && steps.slack-start.outputs.ts != '' && steps.slack-start.outputs.channel_id != '' }}
5252
uses: ./.github/actions/slack-run-finish
5353
with:
5454
channel_id: ${{ steps.slack-start.outputs.channel_id }}

.github/workflows/test-bug-server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: npm run test:server
5050

5151
- name: update slack message
52-
if: ${{ always() && steps.slack-start.outputs.ts != '' }}
52+
if: ${{ always() && steps.slack-start.outputs.ts != '' && steps.slack-start.outputs.channel_id != '' }}
5353
uses: ./.github/actions/slack-run-finish
5454
with:
5555
channel_id: ${{ steps.slack-start.outputs.channel_id }}

.github/workflows/test-module-container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ jobs:
219219
220220
slack-finish:
221221
name: Slack final status
222-
if: ${{ always() && needs.slack-start.result == 'success' && needs.slack-start.outputs.ts != '' }}
222+
if: ${{ always() && needs.slack-start.result == 'success' && needs.slack-start.outputs.ts != '' && needs.slack-start.outputs.channel_id != '' }}
223223
needs:
224224
- slack-start
225225
- discover-modules

.github/workflows/versioning.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ jobs:
138138
139139
slack-finish:
140140
name: Slack final status
141-
if: ${{ always() && needs.slack-start.outputs.ts != '' }}
141+
if: ${{ always() && needs.slack-start.outputs.ts != '' && needs.slack-start.outputs.channel_id != '' }}
142142
needs:
143143
- slack-start
144144
- verify-tests

0 commit comments

Comments
 (0)