Skip to content

Commit

Permalink
add slack notification message on success
Browse files Browse the repository at this point in the history
  • Loading branch information
max-infisical committed Dec 21, 2024
1 parent 634b500 commit e624eeb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/actions/notify-slack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: notify-slack
description: notify slack
inputs:
channel:
description: channel to send message
required: true
token:
description: token with chat:write and chat:write.public permissions
required: true
message:
description: message formatted in Markdown
required: true
runs:
using: composite
steps:
# see https://api.slack.com/tutorials/tracks/posting-messages-with-curl#let-us-hello-then__making-your-messages-more-fantastic
- name: notify-slack
shell: bash
run: |
curl https://slack.com/api/chat.postMessage \
-X POST --fail --silent --show-error \
-H "Authorization: Bearer ${SLACK_TOKEN}" \
-H "Content-type: application/json; charset=utf-8" \
--data @<(yq -pjson -ojson '.channel = env(SLACK_CHANNEL) | .blocks[0].text.text = env(MESSAGE)' <<'EOF'
{
"channel": "<replace me>",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<replace me>"
}
}
]
}
EOF
) >/dev/null
env:
SLACK_CHANNEL: ${{ inputs.channel }}
SLACK_TOKEN: ${{ inputs.token }}
MESSAGE: ${{ inputs.message }}
18 changes: 18 additions & 0 deletions .github/workflows/deployment-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ jobs:
service: infisical-core-gamma-stage
cluster: infisical-gamma-stage
wait-for-service-stability: true
# only notify of success because continue-on-error is so tricky, see https://www.kenmuse.com/blog/how-to-handle-step-and-job-errors-in-github-actions/
- uses: ./.github/actions/notify-slack
with:
token: ${{ secrets.SLACK_TOKEN }}
channel: ${{ secrets.SLACK_CHANNEL }}
message: deployed infisical/staging_infisical:${{ steps.commit.outputs.short }} to ${{ vars.ENVIRONMENT }}

production-us:
name: US production deploy
Expand Down Expand Up @@ -159,6 +165,12 @@ jobs:
service: infisical-core-platform
cluster: infisical-core-platform
wait-for-service-stability: true
# only notify of success because continue-on-error is so tricky, see https://www.kenmuse.com/blog/how-to-handle-step-and-job-errors-in-github-actions/
- uses: ./.github/actions/notify-slack
with:
token: ${{ secrets.SLACK_TOKEN }}
channel: ${{ secrets.SLACK_CHANNEL }}
message: deployed infisical/staging_infisical:${{ steps.commit.outputs.short }} to ${{ vars.ENVIRONMENT }}

production-eu:
name: EU production deploy
Expand Down Expand Up @@ -210,3 +222,9 @@ jobs:
service: infisical-core-platform
cluster: infisical-core-platform
wait-for-service-stability: true
# only notify of success because continue-on-error is so tricky, see https://www.kenmuse.com/blog/how-to-handle-step-and-job-errors-in-github-actions/
- uses: ./.github/actions/notify-slack
with:
token: ${{ secrets.SLACK_TOKEN }}
channel: ${{ secrets.SLACK_CHANNEL }}
message: deployed infisical/staging_infisical:${{ steps.commit.outputs.short }} to ${{ vars.ENVIRONMENT }}

0 comments on commit e624eeb

Please sign in to comment.