-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (127 loc) · 4.81 KB
/
push-main.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
name: Pulumi (Deploy Staging)
on:
push:
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.
concurrency: staging_environment
env:
DEPLOYMENT_ENVIRONMENT: staging
NODE_VERSION: 16.13.1 # 16.13.1 = LTS
jobs:
test_and_build:
name: Test and Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ env.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@v2
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@v2
env:
cache-name: cache-pnpm
with:
# pnpm cache files are stored in `~/.pnpm-store` on Linux/macOS
path: ~/.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 [email protected]
working-directory: editor.planx.uk
- run: pnpm install --frozen-lockfile
working-directory: editor.planx.uk
- run: pnpm test
working-directory: editor.planx.uk
- run: pnpm build
working-directory: editor.planx.uk
env:
REACT_APP_ORDNANCE_SURVEY_KEY: ${{ secrets.ORDNANCE_SURVEY_KEY }}
REACT_APP_API_URL: https://api.editor.planx.dev
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:
name: build
path: ./editor.planx.uk/build
if-no-files-found: error
preview:
name: Pulumi Up
needs: test_and_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
aws-region: eu-west-2
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
- run: npm install -g [email protected]
working-directory: infrastructure/application
- run: pnpm install --frozen-lockfile
working-directory: infrastructure/application
- name: Download Build Artifact
uses: actions/download-artifact@v2
with:
name: build
path: ./editor.planx.uk/build
- uses: pulumi/actions@v3
with:
command: up
stack-name: staging
work-dir: infrastructure/application
edit-pr-comment: true
refresh: 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 }}