Skip to content

Commit da0e27b

Browse files
committed
Replace CircleCI deployments with Github Actions
1 parent e55043e commit da0e27b

File tree

5 files changed

+146
-186
lines changed

5 files changed

+146
-186
lines changed

.circleci/config.yml

Lines changed: 0 additions & 169 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ jobs:
1111
- name: Install Node
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: "lts/*"
15-
cache: 'npm'
14+
node-version: "lts/*"
15+
cache: 'npm'
1616
- name: Create Checksum of package.json
1717
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
1818
- name: Restore Cache
1919
uses: actions/cache/restore@v4
2020
with:
21-
path: ./node_modules
22-
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
21+
path: ./node_modules
22+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
2323
- name: Install Dependencies
2424
run: npm install
2525
- name: Save Cache
2626
uses: actions/cache/save@v4
2727
id: cache
2828
with:
29-
path: ./node_modules
30-
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
29+
path: ./node_modules
30+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
3131
- name: lint javascript
3232
run: npm run lint
3333
test:
@@ -54,22 +54,73 @@ jobs:
5454
- name: Install Node
5555
uses: actions/setup-node@v4
5656
with:
57-
node-version: "lts/*"
58-
cache: 'npm'
57+
node-version: "lts/*"
58+
cache: 'npm'
5959
- name: Create Checksum of package.json
6060
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
6161
- name: Restore Cache
6262
uses: actions/cache/restore@v4
6363
with:
64-
path: ./node_modules
65-
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
64+
path: ./node_modules
65+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
6666
- name: Install Dependencies
6767
run: npm install
6868
- name: Save Cache
6969
uses: actions/cache/save@v4
7070
id: cache
7171
with:
72-
path: ./node_modules
73-
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
72+
path: ./node_modules
73+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
7474
- name: run tests
7575
run: npm test
76+
deploy_dev:
77+
needs:
78+
- lint
79+
- test
80+
if: github.ref == 'refs/heads/develop'
81+
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
82+
with:
83+
APP_NAME: ${{ vars.APP_NAME_DEV }}
84+
DB_NAME: ${{ vars.DB_NAME_DEV }}
85+
NEW_RELIC_APP_NAME:
86+
ORGANIZATION_NAME: gsa-opp-analytics
87+
SPACE_NAME: analytics-dev
88+
secrets:
89+
CF_USERNAME: ${{ secrets.CF_USERNAME_DEV }}
90+
CF_PASSWORD: ${{ secrets.CF_PASSWORD_DEV }}
91+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_DEV }}
92+
NEW_RELIC_LICENSE_KEY:
93+
deploy_stg:
94+
needs:
95+
- lint
96+
- test
97+
if: github.ref == 'refs/heads/staging'
98+
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
99+
with:
100+
APP_NAME: ${{ vars.APP_NAME_STG }}
101+
DB_NAME: ${{ vars.DB_NAME_STG }}
102+
NEW_RELIC_APP_NAME:
103+
ORGANIZATION_NAME: gsa-opp-analytics
104+
SPACE_NAME: analytics-staging
105+
secrets:
106+
CF_USERNAME: ${{ secrets.CF_USERNAME_STG }}
107+
CF_PASSWORD: ${{ secrets.CF_PASSWORD_STG }}
108+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_STG }}
109+
NEW_RELIC_LICENSE_KEY:
110+
deploy_prd:
111+
needs:
112+
- lint
113+
- test
114+
if: github.ref == 'refs/heads/master'
115+
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
116+
with:
117+
APP_NAME: ${{ vars.APP_NAME_PRD }}
118+
DB_NAME: ${{ vars.DB_NAME_PRD }}
119+
NEW_RELIC_APP_NAME: ${{ vars.NEW_RELIC_APP_NAME_PRD }}
120+
ORGANIZATION_NAME: gsa-opp-analytics
121+
SPACE_NAME: analytics-production
122+
secrets:
123+
CF_USERNAME: ${{ secrets.CF_USERNAME_PRD }}
124+
CF_PASSWORD: ${{ secrets.CF_PASSWORD_PRD }}
125+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_PRD }}
126+
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY_PRD }}

.github/workflows/deploy.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
APP_NAME:
5+
required: true
6+
type: string
7+
DB_NAME:
8+
required: true
9+
type: string
10+
NEW_RELIC_APP_NAME:
11+
type: string
12+
ORGANIZATION_NAME:
13+
required: true
14+
type: string
15+
SPACE_NAME:
16+
required: true
17+
type: string
18+
secrets:
19+
CF_USERNAME:
20+
required: true
21+
CF_PASSWORD:
22+
required: true
23+
API_DATA_GOV_SECRET:
24+
required: true
25+
NEW_RELIC_LICENSE_KEY:
26+
27+
jobs:
28+
deploy_api:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Code Checkout
32+
uses: actions/checkout@v4
33+
- name: Install Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "lts/*"
37+
cache: 'npm'
38+
- name: Create Checksum of package.json
39+
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
40+
- name: Restore Cache
41+
uses: actions/cache/restore@v4
42+
with:
43+
path: ./node_modules
44+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
45+
- name: Install Dependencies
46+
run: npm install
47+
- name: Save Cache
48+
uses: actions/cache/save@v4
49+
id: cache
50+
with:
51+
path: ./node_modules
52+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
53+
- name: Replace env vars in manifest.yml file
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install gettext
57+
mv manifest.yml manifest.yml.src
58+
envsubst < manifest.yml.src > manifest.yml
59+
- name: Replace config.js and knexfile.js with .cloudgov versions of those files
60+
run: |
61+
rm ./src/config.js
62+
mv ./src/config.js.cloudgov ./src/config.js
63+
rm knexfile.js
64+
mv knexfile.js.cloudgov knexfile.js
65+
- name: Install CF CLI
66+
run: |
67+
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'
68+
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
69+
- name: Login to cloud.gov and deploy
70+
run: |
71+
set -e
72+
# Log into cloud.gov
73+
cf api api.fr.cloud.gov
74+
cf login -u $CF_USERNAME -p $CF_PASSWORD -o $ORGANIZATION_NAME -s $SPACE_NAME
75+
cat manifest.yml
76+
cf push -f "./manifest.yml"
77+
cf set-env analytics-reporter-api-develop API_DATA_GOV_SECRET "$API_DATA_GOV_SECRET"
78+
cf restage analytics-reporter-api-develop
79+
cf logout

entrypoint.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
export NEW_RELIC_APP_NAME="analytics-reporter-api"
32
export PATH="$PATH:/home/vcap/deps/0/bin"
43
npm run migrate
54
npm start

manifest.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
applications:
2-
- name: analytics-reporter-api
2+
- name: ${APP_NAME}
33
instances: 1
44
memory: 128M
55
buildpacks:
66
- nodejs_buildpack
77
command: "chmod +x ./entrypoint.sh && ./entrypoint.sh"
88
services:
9-
- analytics-reporter-database
9+
- ${DB_NAME}
1010
stack: cflinuxfs4
1111
env:
1212
API_DATA_GOV_SECRET: ${API_DATA_GOV_SECRET}
1313
NEW_RELIC_APP_NAME: ${NEW_RELIC_APP_NAME}
1414
NEW_RELIC_LICENSE_KEY: ${NEW_RELIC_LICENSE_KEY}
15-
NODE_ENV: production
16-
PGSSLMODE: true
15+
NODE_ENV: production
16+
PGSSLMODE: true
1717

0 commit comments

Comments
 (0)