diff --git a/.github/workflows/reusable_cms_deploy.yml b/.github/workflows/reusable_cms_deploy.yml index 6603c933..c5b14d00 100644 --- a/.github/workflows/reusable_cms_deploy.yml +++ b/.github/workflows/reusable_cms_deploy.yml @@ -38,7 +38,7 @@ permissions: contents: read jobs: - deploy-static-site: + deploy-cms: runs-on: ubuntu-latest steps: - name: Checkout @@ -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/slack-github-action@v1.24.0 + 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/slack-github-action@v1.24.0 + 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 }} + diff --git a/.github/workflows/reusable_public_site_deploy.yml b/.github/workflows/reusable_public_site_deploy.yml index 7e52fbb0..35a78496 100644 --- a/.github/workflows/reusable_public_site_deploy.yml +++ b/.github/workflows/reusable_public_site_deploy.yml @@ -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/slack-github-action@v1.24.0 + 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/slack-github-action@v1.24.0 + 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 }} +