-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (125 loc) · 4.67 KB
/
deploy.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: Deploy app to production
on:
repository_dispatch:
types: deploy-prod
env:
CI: true
NODE_ENV: production
DB_URI: ${{ secrets.DB_URI }}
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
jobs:
initial-setup:
name: 'Initial setup'
uses: engagementlab/el-next/.github/workflows/init.yml@main
with:
branch: production
run-cms:
needs: initial-setup
name: 'Run CMS, make build'
# Do not run on automated commits (interpretation of TravisCI feature)
if: "!contains(github.event.head_commit.message, 'skip ci') && github.actor != 'dependabot[bot]'"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.13.1]
steps:
- name: Setup node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Download artifacts from initial-setup job
uses: actions/download-artifact@v4
with:
name: ${{ format('artifact-repo-{0}', github.run_id) }}
- name: Install global packages
run: npm install -g yarn pm2 @preconstruct/cli
- name: Install local monorepo packages and run preconstruct
run: yarn
- name: Generate build notes and summary from user
if: ${{ github.event.client_payload.note != 'null' && github.event.client_payload.note.length > 0 }}
run: |
echo "**Publishing summary from user:**" >> $GITHUB_STEP_SUMMARY
echo "_${{ github.event.client_payload.note }}_" >> $GITHUB_STEP_SUMMARY
- name: Make production build
working-directory: ${{ format('apps/{0}', github.event.client_payload.appName) }}
env:
GRAPHQL_APP: ${{ github.event.client_payload.appName }}
NODE_TLS_REJECT_UNAUTHORIZED: '0'
run: |
yarn add typescript @types/node
yarn
yarn build
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ format('artifact-build-{0}', github.run_id) }}
retention-days: 1
path: |
${{ format('apps/{0}/out', github.event.client_payload.appName) }}
./scripts/upload.sh
./scripts/commit.sh
outputRoutes.mjs
package.json
production-publish:
name: 'Publish new build to production'
needs: [initial-setup, run-cms]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.13.1]
steps:
- name: Download artifacts from production build job
uses: actions/download-artifact@v3
with:
name: ${{ format('artifact-build-{0}', github.run_id) }}
# - name: Install packages
# run: npm i -g pa11y-ci http-server pm2 && npm i
# - name: Serve build
# working-directory: ./
# run: pm2 start `which http-server` --name server
# - name: Output all build paths to .pa11yci config and run pa11y
# run: |
# node outputRoutes.mjs --app ${{ github.event.client_payload.appName }}
# pa11y-ci
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Deploy static build to Azure storage if succeeded
- name: Deploy static build
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch --overwrite true --account-name ${{ github.event.client_payload.storageAccount }} --auth-mode key -d '$web' -s ./apps/${{ github.event.client_payload.appName }}/out
- name: Purge CDN endpoint
uses: azure/CLI@v1
with:
inlineScript: |
az cdn endpoint purge --content-paths "/*" --profile-name web-apps -n ${{ github.event.client_payload.cdnName }} -g web
# Azure logout
- name: logout
run: |
az logout
if: always()
notify-success:
name: Send success Slack notification
needs: [initial-setup, run-cms, production-publish]
if: ${{ success() }}
uses: engagementlab/el-next/.github/workflows/slack.yml@main
with:
apexUrl: ${{ github.event.client_payload.apexUrl }}
note: ${{ github.event.client_payload.note }}
userName: ${{ github.event.client_payload.userName }}
success: true
secrets: inherit
notify-failure:
name: Send failure Slack notification
needs: [initial-setup, run-cms, production-publish]
if: ${{ failure() }}
uses: engagementlab/el-next/.github/workflows/slack.yml@main
with:
apexUrl: ${{ github.event.client_payload.apexUrl }}
note: ${{ github.event.client_payload.note }}
userName: ${{ github.event.client_payload.userName }}
success: false
secrets: inherit