-
Notifications
You must be signed in to change notification settings - Fork 153
169 lines (166 loc) · 5.75 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Shared deploy job
on:
workflow_call:
inputs:
ANALYTICS_GA4_CALL_RETRY_COUNT:
required: false
type: string
ANALYTICS_KEY_FILE_NAME:
required: true
type: string
ANALYTICS_LOG_LEVEL:
required: true
type: string
ANALYTICS_REPORT_EMAIL:
required: true
type: string
APP_NAME:
required: true
type: string
CF_ORGANIZATION_NAME:
required: true
type: string
CF_SPACE_NAME:
required: true
type: string
DB_SERVICE_NAME:
required: true
type: string
MESSAGE_QUEUE_DATABASE_NAME:
required: true
type: string
MESSAGE_QUEUE_NAME:
required: true
type: string
NEW_RELIC_APP_NAME:
type: string
PROXY_FQDN:
required: true
type: string
PROXY_PORT:
required: true
type: string
S3_SERVICE_NAME:
required: true
type: string
secrets:
ANALYTICS_CREDENTIALS:
required: true
CF_USERNAME:
required: true
CF_PASSWORD:
required: true
GA4_CREDS:
required: true
NEW_RELIC_LICENSE_KEY:
PROXY_USERNAME:
required: true
PROXY_PASSWORD:
required: true
env:
ANALYTICS_CREDENTIALS: ${{ secrets.ANALYTICS_CREDENTIALS }}
ANALYTICS_GA4_CALL_RETRY_COUNT: ${{ inputs.ANALYTICS_GA4_CALL_RETRY_COUNT }}
ANALYTICS_KEY_FILE_NAME: ${{ inputs.ANALYTICS_KEY_FILE_NAME }}
ANALYTICS_LOG_LEVEL: ${{ inputs.ANALYTICS_LOG_LEVEL }}
ANALYTICS_REPORT_EMAIL: ${{ inputs.ANALYTICS_REPORT_EMAIL }}
APP_NAME: ${{ inputs.APP_NAME }}
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORGANIZATION_NAME: ${{ inputs.CF_ORGANIZATION_NAME }}
CF_SPACE_NAME: ${{ inputs.CF_SPACE_NAME }}
DB_SERVICE_NAME: ${{ inputs.DB_SERVICE_NAME }}
GA4_CREDS: ${{ secrets.GA4_CREDS }}
MESSAGE_QUEUE_DATABASE_NAME: ${{ inputs.MESSAGE_QUEUE_DATABASE_NAME }}
MESSAGE_QUEUE_NAME: ${{ inputs.MESSAGE_QUEUE_NAME }}
NEW_RELIC_APP_NAME: ${{ inputs.NEW_RELIC_APP_NAME }}
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
PROXY_FQDN: ${{ inputs.PROXY_FQDN }}
PROXY_PORT: ${{ inputs.PROXY_PORT }}
PROXY_USERNAME: ${{ secrets.PROXY_USERNAME }}
PROXY_PASSWORD: ${{ secrets.PROXY_PASSWORD }}
S3_SERVICE_NAME: ${{ inputs.S3_SERVICE_NAME }}
jobs:
deploy_reporter_publisher:
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: 'npm'
- name: Install node dependencies
# This causes npm install to omit dev dependencies per NPM docs.
env:
NODE_ENV: production
run: npm ci
- name: Install cloud foundry CLI for interacting with cloud.gov
run: |
sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
- name: Write Google GA4 Credentials file from the value in GA4_CREDS env var.
run: |
echo $GA4_CREDS > ./my-analytics-ga4-65057af58daa.json
- name: Run envsubst on manifest.yml to set environment specific values
run: |
mv manifest.publisher.yml manifest.yml.src
envsubst < manifest.yml.src > manifest.yml
cat manifest.yml
- name: Replace knexfile.js with .cloudgov version of that file
run: |
rm knexfile.js
mv knexfile.cloudgov.js knexfile.js
- name: Login to cloud.gov and deploy
run: |
set -e
# Log into cloud.gov
cf api api.fr.cloud.gov
cf login -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORGANIZATION_NAME -s $CF_SPACE_NAME
# Stop the running app (to save memory of two instances running until staging is complete)
cf stop $APP_NAME-publisher
# Deploy app
cf push -f "./manifest.yml"
cf logout
deploy_reporter_consumer:
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: 'npm'
- name: Install node dependencies
# This causes npm install to omit dev dependencies per NPM docs.
env:
NODE_ENV: production
run: npm ci
- name: Install cloud foundry CLI for interacting with cloud.gov
run: |
sudo curl -v -L -o cf8-cli-installer_8.7.4_x86-64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.7.4'
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
- name: Write Google GA4 Credentials file from the value in GA4_CREDS env var.
run: |
echo $GA4_CREDS > ./my-analytics-ga4-65057af58daa.json
- name: Run envsubst on manifest.yml to set environment specific values
run: |
mv manifest.consumer.yml manifest.yml.src
envsubst < manifest.yml.src > manifest.yml
cat manifest.yml
- name: Replace knexfile.js with .cloudgov version of that file
run: |
rm knexfile.js
mv knexfile.cloudgov.js knexfile.js
- name: Login to cloud.gov and deploy
run: |
set -e
# Log into cloud.gov
cf api api.fr.cloud.gov
cf login -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORGANIZATION_NAME -s $CF_SPACE_NAME
# Stop the running app (to save memory of two instances running until staging is complete)
cf stop $APP_NAME-consumer
# Deploy app
cf push -f "./manifest.yml"
cf logout