forked from USEPA/mywaterway
-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (113 loc) · 4.94 KB
/
dev.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
# This is a basic workflow to help you get started with Actions
name: Dev Deploy
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch branches: [ develop ]
push:
branches: [ develop ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
changes:
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: dev
outputs:
workflows: ${{ steps.filter.outputs.workflows }}
app: ${{ steps.filter.outputs.app }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
workflows:
- '.github/workflows/dev.yml'
app:
- 'app/**'
app:
# Check if this folder has any changes
needs: changes
if: ${{
needs.changes.outputs.app == 'true' ||
needs.changes.outputs.workflows == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: dev
# Set environment variables
env:
APP_NAME: mywaterway-dev
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE_DEV }}
CF_STACK: cflinuxfs4
CF_USER_DEV: ${{ secrets.CF_USER_DEV }}
CF_PASSWORD_DEV: ${{ secrets.CF_PASSWORD_DEV }}
CF_S3_PUB_ACCESS_KEY: ${{ secrets.CF_DEV_S3_PUB_ACCESS_KEY }}
CF_S3_PUB_BUCKET_ID: ${{ secrets.CF_DEV_S3_PUB_BUCKET_ID }}
CF_S3_PUB_REGION: ${{ secrets.CF_DEV_S3_PUB_REGION }}
CF_S3_PUB_SECRET_KEY: ${{ secrets.CF_DEV_S3_PUB_SECRET_KEY }}
GLOSSARY_AUTH: ${{ secrets.GLOSSARY_AUTH }}
HMW_BASIC_USER_NAME: ${{ secrets.HMW_BASIC_USER_NAME }}
HMW_BASIC_USER_PWD: ${{ secrets.HMW_BASIC_USER_PWD }}
REACT_APP_ARCGIS_CLIENT_ID: ${{ secrets.REACT_APP_ARCGIS_CLIENT_ID_DEV }}
SERVER_URL: https://mywaterway-dev.app.cloud.gov
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Set up node and npm
- uses: actions/setup-node@v3
# Run front-end processes (install, lint, test, bundle)
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/client/.npm
key: v1-npm-client-deps-${{ hashFiles('**/client/package-lock.json') }}
restore-keys: v1-npm-client-deps-
- name: Install front-end dependencies
run: npm install --legacy-peer-deps
working-directory: app/client
- name: Build front-end files and move to server
run: |
REACT_APP_ARCGIS_CLIENT_ID="$REACT_APP_ARCGIS_CLIENT_ID" \
npm run build
cd build
cp -r * ../../server/app/public
rm -rf *
working-directory: app/client
# Run CloudFoundry/Cloud.gov deployment
- name: Set up Cloud Foundry CLI
run: |
curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&version=v7&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
cf api https://api.fr.cloud.gov
cf auth "$CF_USER_DEV" "$CF_PASSWORD_DEV"
cf target -o "$CF_ORG" -s "$CF_SPACE"
- name: Set application-level variables
run: |
cf set-env $APP_NAME "GLOSSARY_AUTH" "$GLOSSARY_AUTH" > /dev/null
cf set-env $APP_NAME "HMW_BASIC_USER_NAME" "$HMW_BASIC_USER_NAME" > /dev/null
cf set-env $APP_NAME "HMW_BASIC_USER_PWD" "$HMW_BASIC_USER_PWD" > /dev/null
cf set-env $APP_NAME "TZ" "America/New_York" > /dev/null
- name: Configure Public AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ env.CF_S3_PUB_ACCESS_KEY }}
aws-secret-access-key: ${{ env.CF_S3_PUB_SECRET_KEY }}
aws-region: ${{ env.CF_S3_PUB_REGION }}
# Sync static content to public S3 bucket
- name: Sync static content to S3
run: aws s3 sync . s3://$CF_S3_PUB_BUCKET_ID/data
working-directory: app/server/app/public/data
# Set CORS configuration for public S3 bucket
- name: Set public S3 CORS configuration
run: aws s3api put-bucket-cors --bucket $CF_S3_PUB_BUCKET_ID --cors-configuration file://s3CORS.json
working-directory: app/server/app/config
# Now that front-end is built in server/dist, only push server dir to Cloud.gov
- name: Deploy application to Cloud.gov
run: cf push $APP_NAME --strategy rolling -f ../manifest-dev.yml -p . -t 180 -s $CF_STACK
working-directory: app/server