Skip to content

Commit

Permalink
feat: Airbrake & Slack deployment notifications (#551)
Browse files Browse the repository at this point in the history
- Sends notifications to airbrake and slack after deploying to staging or production
- Introduces airbrake staging and pullrequest environments
- Prevents development errors from being sent to airbrake
  • Loading branch information
johnrees authored Jul 2, 2021
1 parent c6c9be3 commit 40b05ad
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull-request-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ jobs:
REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1
REACT_APP_HASURA_URL: https://hasura.editor.planx.dev/v1/graphql
REACT_APP_SHAREDB_URL: wss://sharedb.editor.planx.dev
REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v2
with:
Expand Down
34 changes: 33 additions & 1 deletion .github/workflows/push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
branches:
- main

# When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress, the queued job or workflow will be pending. Any previously pending job or workflow in the concurrency group will be canceled.
# When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress,
# the queued job or workflow will be pending. Any previously pending job or workflow in the concurrency group will be canceled.
concurrency: staging_environment

env:
DEPLOYMENT_ENVIRONMENT: staging

jobs:
test_and_build:
name: Test and Build
Expand Down Expand Up @@ -56,6 +60,8 @@ jobs:
REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1
REACT_APP_HASURA_URL: https://hasura.editor.planx.dev/v1/graphql
REACT_APP_SHAREDB_URL: wss://sharedb.editor.planx.dev
REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -97,3 +103,29 @@ jobs:
edit-pr-comment: true
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}

notifications:
name: Notifications
needs: preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Airbrake notification - https://airbrake.io/docs/features/deploy-tracking
- name: Notify Airbrake of deploy
id: airbrake-deploy
uses: mtchavez/airbrake-deploy@v1
with:
project-id: ${{ secrets.AIRBRAKE_PROJECT_ID }}
project-key: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
environment: ${{ env.DEPLOYMENT_ENVIRONMENT }}
repository: https://github.com${{ github.repo }}
revision: ${{ github.sha }}
user: ${{ github.actor }}
- name: Get Airbrake deploy response
run: echo "The response was ${{ steps.airbrake-deploy.outputs.response }}"
# Slack deployment notification
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TITLE: ${{ env.DEPLOYMENT_ENVIRONMENT }} deploy
SLACK_WEBHOOK: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK }}
34 changes: 33 additions & 1 deletion .github/workflows/push-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ on:
branches:
- production

# When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress, the queued job or workflow will be pending. Any previously pending job or workflow in the concurrency group will be canceled.
# When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress,
# the queued job or workflow will be pending. Any previously pending job or workflow in the concurrency group will be canceled.
concurrency: production_environment

env:
DEPLOYMENT_ENVIRONMENT: production

jobs:
test_and_build:
name: Test and Build
Expand Down Expand Up @@ -56,6 +60,8 @@ jobs:
REACT_APP_FEEDBACK_FISH_ID: 65f02de00b90d1
REACT_APP_HASURA_URL: https://hasura.editor.planx.uk/v1/graphql
REACT_APP_SHAREDB_URL: wss://sharedb.editor.planx.uk
REACT_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
REACT_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -97,3 +103,29 @@ jobs:
edit-pr-comment: true
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}

notifications:
name: Notifications
needs: preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Airbrake notification - https://airbrake.io/docs/features/deploy-tracking
- name: Notify Airbrake of deploy
id: airbrake-deploy
uses: mtchavez/airbrake-deploy@v1
with:
project-id: ${{ secrets.AIRBRAKE_PROJECT_ID }}
project-key: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
environment: ${{ env.DEPLOYMENT_ENVIRONMENT }}
repository: https://github.com${{ github.repo }}
revision: ${{ github.sha }}
user: ${{ github.actor }}
- name: Get Airbrake deploy response
run: echo "The response was ${{ steps.airbrake-deploy.outputs.response }}"
# Slack deployment notification
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TITLE: ${{ env.DEPLOYMENT_ENVIRONMENT }} deploy
SLACK_WEBHOOK: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK }}
3 changes: 0 additions & 3 deletions editor.planx.uk/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
REACT_APP_MAPBOX_ACCESS_TOKEN=pk.eyJ1Ijoib3BlbnN5c3RlbXNsYWIiLCJhIjoiY2sybHJ6cnY2MGFkaTNjcHIwanV1eGRlbCJ9.xAHUuQo1RAnzwOlN90SGVQ
REACT_APP_ORDNANCE_SURVEY_KEY=se00yjrqJx8ypuQZ84GGdvYrzOEXJzOU

REACT_APP_AIRBRAKE_PROJECT_ID=329753
REACT_APP_AIRBRAKE_PROJECT_KEY=388fe6f4cc0d6644c923500d5672a5b6

# used in dev/test, overwritten in .env.production

REACT_APP_API_URL=http://localhost:7002
Expand Down
8 changes: 6 additions & 2 deletions editor.planx.uk/src/airbrake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { Notifier } from "@airbrake/browser";

// forward all JS errors to airbrake.io
export const airbrake =
process.env.NODE_ENV !== "test" &&
process.env.NODE_ENV === "production" &&
process.env.REACT_APP_AIRBRAKE_PROJECT_ID &&
process.env.REACT_APP_AIRBRAKE_PROJECT_KEY
? new Notifier({
projectId: Number(process.env.REACT_APP_AIRBRAKE_PROJECT_ID),
projectKey: process.env.REACT_APP_AIRBRAKE_PROJECT_KEY,
environment: process.env.NODE_ENV,
environment: window.location.host.endsWith("planx.uk")
? "production"
: window.location.host.endsWith("planx.dev")
? "staging"
: "pullrequest",
})
: undefined;

0 comments on commit 40b05ad

Please sign in to comment.