Skip to content

Commit

Permalink
Add slack failure notifications to the build-and-deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
johnake committed Mar 5, 2024
1 parent 253908b commit 0af551e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions/database-backup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ runs:
echo "envs are: ${{ env.INF_VAULT_NAME }} ${{ env.NAMESPACE }} ${{ env.APP_ENVIRONMENT }} ${{ env.CLUSTER }}"
- uses: Azure/login@v1
- uses: Azure/login@v2
with:
creds: ${{ inputs.azure_credentials }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/actions/deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ runs:
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}

- uses: azure/login@v1
- uses: azure/login@v2
with:
creds: ${{ inputs.azure-credentials }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/actions/smoke-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
using: composite

steps:
- uses: Azure/login@v1
- uses: Azure/login@v2
with:
creds: ${{ inputs.azure_credentials }}

Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,43 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Fetch secrets from key vault
uses: azure/CLI@v1
id: keyvault-yaml-secret
with:
inlineScript: |
SLACK_WEBHOOK=$(az keyvault secret show --name "SLACK-WEBHOOK" --vault-name "${{ secrets.INF_KEY_VAULT }}" --query "value" -o tsv)
echo "::add-mask::$SLACK_WEBHOOK"
echo "SLACK_WEBHOOK=$SLACK_WEBHOOK" >> $GITHUB_OUTPUT
- uses: ./.github/workflows/actions/deploy
id: deploy
with:
environment: ${{ matrix.environment }}
docker_image: ${{ needs.docker.outputs.docker_image }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
arm-access-key: ${{ secrets.ARM_ACCESS_KEY }}

- uses: ./.github/workflows/actions/smoke-test
id: smoke-test
with:
environment: ${{ matrix.environment }}
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}

- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: failure
SLACK_TITLE: Failure deploying release to ${{ matrix.environment }}
SLACK_MESSAGE: Failure deploying release to ${{ matrix.environment }} - Docker tag ${{ needs.docker.outputs.docker_image }}
SLACK_WEBHOOK: ${{ steps.keyvault-yaml-secret.outputs.SLACK_WEBHOOK }}

deploy_production:
name: Deploy to production environment
runs-on: ubuntu-latest
Expand All @@ -106,10 +130,33 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Fetch secrets from key vault
uses: azure/CLI@v1
id: keyvault-yaml-secret
with:
inlineScript: |
SLACK_WEBHOOK=$(az keyvault secret show --name "SLACK-WEBHOOK" --vault-name "${{ secrets.INF_KEY_VAULT }}" --query "value" -o tsv)
echo "::add-mask::$SLACK_WEBHOOK"
echo "SLACK_WEBHOOK=$SLACK_WEBHOOK" >> $GITHUB_OUTPUT
- uses: ./.github/workflows/actions/deploy
id: deploy
with:
environment: production
docker_image: ${{ needs.docker.outputs.docker_image }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
arm-access-key: ${{ secrets.ARM_ACCESS_KEY }}

- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: failure
SLACK_TITLE: Failure deploying release to production
SLACK_MESSAGE: Failure deploying release to production - Docker tag ${{ needs.docker.outputs.docker_image }}
SLACK_WEBHOOK: ${{ steps.keyvault-yaml-secret.outputs.SLACK_WEBHOOK }}
2 changes: 1 addition & 1 deletion .github/workflows/delete-review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
echo "CLUSTER=$CLUSTER" >> $GITHUB_ENV
echo "APP_ENVIRONMENT=$APP_ENVIRONMENT" >> $GITHUB_ENV
- uses: Azure/login@v1
- uses: Azure/login@v2
with:
creds: ${{ secrets.azure_credentials }}

Expand Down

0 comments on commit 0af551e

Please sign in to comment.