Skip to content

Commit 892ea3d

Browse files
authored
reduce slack message if success + use global slack webhook url (#196)
Signed-off-by: Nicolas Rol <[email protected]>
1 parent 9fc4b89 commit 892ea3d

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

Diff for: .github/workflows/snapshot-ci.yml

+36-11
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,31 @@ jobs:
203203
formatted="${formatted%\\n}" # Remove the last newline
204204
echo "formatted_results=${formatted}" >> $GITHUB_OUTPUT
205205
206-
- name: Send Slack Notification
207-
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
208-
with:
209-
author_name: 'powsybl-metrix on GitHub'
210-
status: custom
211-
custom_payload: |
212-
{
213-
attachments: [{
214-
color: '${{ job.status }}' === 'success' ? "#319f4b" : '${{ job.status }}' === 'failure' ? "#f64538" : "#ffc965",
206+
- name: Prepare Slack payload
207+
id: prepare_payload
208+
run: |
209+
if [ "${{ steps.workflow_status.outputs.status }}" == "Successful" ]; then
210+
echo 'payload<<EOF' >> $GITHUB_OUTPUT
211+
echo '{
212+
"attachments": [{
213+
"color": "#319f4b",
214+
"blocks": [
215+
{
216+
"type": "section",
217+
"text": {
218+
"type": "mrkdwn",
219+
"text": "${{ steps.workflow_status.outputs.icon }} *${{ steps.workflow_status.outputs.status }} workflow: Snapshot-CI on <https://github.com/powsybl/powsybl-metrix|powsybl-metrix>*\n\nBranch built: ${{ needs.build_powsybl_metrix.outputs.metrix-branch }}\nPowSyBl-Core version used: ${{ needs.build_powsybl_metrix.outputs.core-version }}\n\nSee logs on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|GitHub>"
220+
}
221+
}
222+
]
223+
}]
224+
}' >> $GITHUB_OUTPUT
225+
echo 'EOF' >> $GITHUB_OUTPUT
226+
else
227+
echo 'payload<<EOF' >> $GITHUB_OUTPUT
228+
echo '{
229+
"attachments": [{
230+
"color": "#f64538",
215231
"blocks": [
216232
{
217233
"type": "section",
@@ -232,6 +248,15 @@ jobs:
232248
}
233249
]
234250
}]
235-
}
251+
}' >> $GITHUB_OUTPUT
252+
echo 'EOF' >> $GITHUB_OUTPUT
253+
fi
254+
255+
- name: Send Slack Notification
256+
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
257+
with:
258+
author_name: 'powsybl-metrix on GitHub'
259+
status: custom
260+
custom_payload: ${{ steps.prepare_payload.outputs.payload }}
236261
env:
237-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_METRIX }}
262+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_POWSYBL_WEBHOOK_URL }}

0 commit comments

Comments
 (0)