Skip to content

Commit

Permalink
send slack notification when deploy to staging and prod
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung authored and JeromeBu committed Jan 23, 2025
1 parent 2aeed62 commit 6b8ef62
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ jobs:
environment: staging
tag: "v${{ github.run_number }}"
isPreRelease: true
slackChannel: "#if-staging-déploiement"
secrets:
SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

deploy-pentest:
name: Deploy pentest
Expand All @@ -86,9 +88,11 @@ jobs:
tag: "v${{ github.run_number }}"
region: "osc-secnum-fr1"
isPreRelease: false
slackChannel: "#if-prod-déploiement"
secrets:
SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }}
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

create-release:
needs:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/deploy-to-scalingo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ on:
required: false
type: string
default: "osc-fr1"
slackChannel:
type: string
required: true
secrets:
SCALINGO_API_TOKEN:
required: true
DISCORD_WEBHOOK_URL:
required: true
SLACK_BOT_TOKEN:
required: true

jobs:
deploy:
Expand Down Expand Up @@ -49,6 +54,53 @@ jobs:
run: scalingo --app if-${{ inputs.environment }}-back --region ${{ inputs.region }} deploy back-build.tar.gz ${{ inputs.tag }}
- name: Deploy front
run: scalingo --app if-${{ inputs.environment }}-front --region ${{ inputs.region }} deploy front-build.tar.gz ${{ inputs.tag }}
- name: Send Slack notification
run: |
releaseSuffix=$([[ "${{ inputs.isPreRelease }}" == "true" ]] && echo "-rc" || echo "")
curl --location "https://slack.com/api/chat.postMessage" -H "Content-Type: application/json" -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" -d @- <<EOF
{
"channel": "${{ inputs.slackChannel }}",
"blocks": [
{"type": "header", "text": {"type": "plain_text", "text": "${{ inputs.tag }}${releaseSuffix}"}},
{"type": "section", "text": {"type": "plain_text", "text": "La version ${{ inputs.tag }}${releaseSuffix} est déployée en ${{ inputs.environment }}${releaseSuffix}."}},
{
"type": "actions",
"elements": [
{
"type": "button",
"style": "primary",
"text": {
"type": "plain_text",
"text": "Voir les changements"
},
"url": "https://github.com/gip-inclusion/immersion-facile/releases/tag/${{ inputs.tag }}${releaseSuffix}"
}, {
"type": "button",
"text": {
"type": "plain_text",
"text": "Voir les releases"
},
"url": "https://github.com/gip-inclusion/immersion-facile/releases"
}, {
"type": "button",
"text": {
"type": "plain_text",
"text": "Aller sur l'application"
},
"url": "https://${{ inputs.environment }}.immersion-facile.beta.gouv.fr"
}, {
"type": "button",
"text": {
"type": "plain_text",
"text": "Voir le workfow github"
},
"url": "${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
EOF
- name: Send Discord notification
run: |
releaseSuffix=$([[ "${{ inputs.isPreRelease }}" == "true" ]] && echo "-rc" || echo "")
Expand Down

0 comments on commit 6b8ef62

Please sign in to comment.