-
Notifications
You must be signed in to change notification settings - Fork 2
141 lines (135 loc) · 5.1 KB
/
push-production.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Pulumi (Deploy Production)
on:
push:
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.
concurrency: production_environment
env:
DEPLOYMENT_ENVIRONMENT: production
jobs:
build_react:
name: Test and Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
# https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#using-the-cache-action
- name: NPM cache
uses: actions/cache@v4
env:
cache-name: cache-npm
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: PNPM cache
uses: actions/cache@v4
env:
cache-name: cache-pnpm
with:
# pnpm cache files are stored in `~/.local/share/pnpm/store` on Linux
path: ~/.local/share/pnpm/store
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm install -g pnpm@${{ vars.PNPM_VERSION }}
- name: Setup .gitconfig
run: mv .gitconfig ~/.gitconfig
- run: pnpm install --frozen-lockfile
working-directory: editor.planx.uk
- run: pnpm build
working-directory: editor.planx.uk
env:
VITE_APP_AIRBRAKE_PROJECT_ID: ${{ secrets.AIRBRAKE_PROJECT_ID }}
VITE_APP_AIRBRAKE_PROJECT_KEY: ${{ secrets.AIRBRAKE_PROJECT_KEY }}
VITE_APP_API_URL: https://api.editor.planx.uk
VITE_APP_ENV: production
VITE_APP_HASURA_URL: https://hasura.editor.planx.uk/v1/graphql
VITE_APP_HASURA_WEBSOCKET: wss://hasura.editor.planx.uk/v1/graphql
VITE_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN }}
VITE_APP_SHAREDB_URL: wss://sharedb.editor.planx.uk
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build
path: ./editor.planx.uk/build
if-no-files-found: error
preview:
name: Pulumi Up
needs: build_react
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PRODUCTION_AWS_ACCESS_KEY_ID }}
aws-region: eu-west-2
aws-secret-access-key: ${{ secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY }}
- run: npm install -g pnpm@${{ vars.PNPM_VERSION }}
working-directory: infrastructure/application
- run: pnpm install --frozen-lockfile
working-directory: infrastructure/application
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build
path: ./editor.planx.uk/build
- uses: pulumi/actions@v5
with:
command: up
stack-name: production
work-dir: infrastructure/application
edit-pr-comment: true
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
notifications:
name: Notifications
needs: preview
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
# 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_USERNAME: PlanX Deploy
SLACK_COLOR: "#42AC6A"
SLACK_TITLE: ${{ env.DEPLOYMENT_ENVIRONMENT }} deploy
SLACK_WEBHOOK: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK }}
failure_notification:
name: Send failure notification
needs: preview
if: failure()
uses: ./.github/workflows/action-failure.yml
secrets: inherit
with:
environment: Production