Skip to content

Commit

Permalink
ci: add slack notifications on ci dployment (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgerard-pass authored Feb 6, 2024
1 parent dcdcbdd commit ee2bc07
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 1 deletion.
71 changes: 70 additions & 1 deletion .github/workflows/reusable_cms_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ permissions:
contents: read

jobs:
deploy-static-site:
deploy-cms:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -96,3 +96,72 @@ jobs:
kubectl config set-context --current --namespace=argocd
argocd app set site-instit-${{ inputs.environment }} --core --plugin-env "ARGS=--set deployment.image.tag=${{ inputs.image_tag }}"
argocd app wait site-instit-${{ inputs.environment }} --core --sync --health --timeout 180
notification:
name: "Notification"
runs-on: ubuntu-latest
needs: [deploy-cms]
if: ${{ always() }}
steps:
- name: "Authentification to Google"
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.SECRETS_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SECRETS_SERVICE_ACCOUNT }}
- name: "Get Secret"
id: 'secrets'
uses: 'google-github-actions/get-secretmanager-secrets@v2'
with:
secrets: |-
SLACK_BOT_TOKEN:passculture-metier-ehp/passculture-ci-slack-bot-token
- name: "Post to a Slack channel on success"
if: ${{ always() && contains(needs.deploy-cms.result, 'success') }}
uses: slackapi/[email protected]
with:
# channel #alertes-deploiement-site-instit
channel-id: "C06EKUL552T"
payload: |
{
"attachments": [
{
"mrkdwn_in": ["text"],
"color": "#36A64F",
"author_name": "${{github.actor}}",
"author_link": "https://github.com/${{github.actor}}",
"author_icon": "https://github.com/${{github.actor}}.png",
"title": "CMS Site instit",
"title_link": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
"text": "Le CMS du site instit vient d'être déployé en ${{ inputs.environment }} :white_check_mark:"
}
],
"unfurl_links": false,
"unfurl_media": false
}
env:
SLACK_BOT_TOKEN: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }}
- name: "Post to a Slack channel on failure"
if: ${{ always() && contains(needs.deploy-cms.result, 'failure') }}
uses: slackapi/[email protected]
with:
# channel #alertes-deploiement-site-instit
channel-id: "C06EKUL552T"
payload: |
{
"attachments": [
{
"mrkdwn_in": ["text"],
"color": "#A30002",
"author_name": "${{github.actor}}",
"author_link": "https://github.com/${{github.actor}}",
"author_icon": "https://github.com/${{github.actor}}.png",
"title": "CMS Site Instit",
"title_link": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
"text": "Le déploiement du CMS site instit vient d'échouer en ${{ inputs.environment }} :boom:"
}
],
"unfurl_links": false,
"unfurl_media": false
}
env:
SLACK_BOT_TOKEN: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }}

69 changes: 69 additions & 0 deletions .github/workflows/reusable_public_site_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,72 @@ jobs:
run: |
firebase use pc-site-instit-${{ inputs.environment }}
firebase deploy --only hosting:${{ inputs.environment }} --project pc-site-instit-${{ inputs.environment }} --non-interactive
notification:
name: "Notification"
runs-on: ubuntu-latest
needs: [deploy-static-site]
if: ${{ always() }}
steps:
- name: "Authentification to Google"
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.SECRETS_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SECRETS_SERVICE_ACCOUNT }}
- name: "Get Secret"
id: 'secrets'
uses: 'google-github-actions/get-secretmanager-secrets@v2'
with:
secrets: |-
SLACK_BOT_TOKEN:passculture-metier-ehp/passculture-ci-slack-bot-token
- name: "Post to a Slack channel on success"
if: ${{ always() && contains(needs.deploy-static-site.result, 'success') }}
uses: slackapi/[email protected]
with:
# channel #alertes-deploiement-site-instit
channel-id: "C06EKUL552T"
payload: |
{
"attachments": [
{
"mrkdwn_in": ["text"],
"color": "#36A64F",
"author_name": "${{github.actor}}",
"author_link": "https://github.com/${{github.actor}}",
"author_icon": "https://github.com/${{github.actor}}.png",
"title": "Site instit public",
"title_link": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
"text": "Le site instit vient d'être déployé en ${{ inputs.environment }} :white_check_mark:"
}
],
"unfurl_links": false,
"unfurl_media": false
}
env:
SLACK_BOT_TOKEN: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }}
- name: "Post to a Slack channel on failure"
if: ${{ always() && contains(needs.deploy-static-site.result, 'failure') }}
uses: slackapi/[email protected]
with:
# channel #alertes-deploiement-site-instit
channel-id: "C06EKUL552T"
payload: |
{
"attachments": [
{
"mrkdwn_in": ["text"],
"color": "#A30002",
"author_name": "${{github.actor}}",
"author_link": "https://github.com/${{github.actor}}",
"author_icon": "https://github.com/${{github.actor}}.png",
"title": "Site instit public",
"title_link": "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}",
"text": "Le déploiement du site instit vient d'échouer en ${{ inputs.environment }} :boom:"
}
],
"unfurl_links": false,
"unfurl_media": false
}
env:
SLACK_BOT_TOKEN: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }}

0 comments on commit ee2bc07

Please sign in to comment.