forked from usds/assessment-review-tool
-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (93 loc) · 3.5 KB
/
push-prod.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
# This is a basic workflow to help you get started with Actions
name: Deploy Prod
# Controls when the workflow will run
on:
push:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# workflow_call:
# secrets:
# STAGE_CF_USERNAME:
# description: cf-login username
# required: true
# STAGE_CF_PASSWORD:
# description: cf-login password
# required: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
with:
ref: ${{ inputs.branch_name }}
# - uses: actions/cache@v2
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
- uses: actions/cache@v2
id: api-npm-cache
with:
path: ./api/node_modules/
key: ${{ runner.os }}-api-npm-${{ hashFiles('./api/package-lock.json') }}
- uses: actions/cache@v2
id: frontend-npm-cache
with:
path: ./frontend/node_modules/
key: ${{ runner.os }}-frontend-npm-${{ hashFiles('./frontend/package-lock.json') }}
- uses: actions/cache@v2
id: frontend-scss-cache
with:
path: ./frontend/src/styles/
key: ${{ runner.os }}-frontend-scss-${{ hashFiles('./frontend/src/scss/**.scss') }}
# Notice that the cache for the frontend is actually in the api directory... where it dumps out after it's done.
- uses: actions/cache@v2
id: frontend-src-cache
with:
path: ./api/src/client
key: ${{ runner.os }}-frontend-src-prod-${{ hashFiles('./frontend/src/**/*', './frontend/package.json') }}
# Build frontend (requires node 12)
- uses: actions/setup-node@v2
with:
node-version: "12"
- name: Install frontend dependencies
if: steps.frontend-npm-cache.outputs.cache-hit != 'true'
run: npm ci
working-directory: frontend
- name: Build frontend styles
if: steps.frontend-scss-cache.outputs.cache-hit != 'true'
run: npm run build:styles
working-directory: frontend
- name: Build frontend
if: steps.frontend-src-cache.outputs.cache-hit != 'true'
run: npm run build:prod
working-directory: frontend
# Build backend (requires node 14)
- uses: actions/setup-node@v2
with:
node-version: "14"
- name: Install dependencies
if: steps.api-npm-cache.outputs.cache-hit != 'true'
run: npm ci
working-directory: api
# Because of how the deploy works, do not cache backend
# frontend changes _will not_ make it if that's the case
- name: Build backend
run: npm run build
working-directory: api
- name: Deploy to cloud.gov
uses: cloud-gov/cg-cli-tools@main
with:
cf_api: https://api.fr.cloud.gov
cf_username: ${{secrets.PROD_CF_USERNAME}}
cf_password: ${{secrets.PROD_CF_PASSWORD}}
cf_org: gsa-tts-usdc
cf_space: prod
cf_manifest: deployProd.yml
cf_command: push smeqa-rr -f deployProd.yml --strategy rolling -i 2