Skip to content

Commit 6997746

Browse files
committed
Rename some CI variables for clarity, enhance docs
1 parent a1380ed commit 6997746

File tree

5 files changed

+57
-75
lines changed

5 files changed

+57
-75
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Code Checkout
9+
- name: Code checkout
1010
uses: actions/checkout@v4
11-
- name: Install Node
11+
- name: Install node
1212
uses: actions/setup-node@v4
1313
with:
1414
node-version: "lts/*"
1515
cache: 'npm'
16-
- name: install dependencies
16+
- name: Install node dependencies
1717
run: npm ci
18-
- name: lint javascript
18+
- name: Lint javascript
1919
run: npm run lint
2020
test:
2121
needs: lint
2222
runs-on: ubuntu-latest
23-
#Spin up postgres as a service, wait till healthy before moving on. Uses latest Postgres Version.
23+
# Start Postgres as a service, wait until healthy. Uses latest Postgres version.
2424
services:
2525
postgres:
2626
image: postgres:latest
@@ -36,16 +36,16 @@ jobs:
3636
--health-timeout 5s
3737
--health-retries 5
3838
steps:
39-
- name: Code Checkout
39+
- name: Code checkout
4040
uses: actions/checkout@v4
41-
- name: Install Node
41+
- name: Install node
4242
uses: actions/setup-node@v4
4343
with:
4444
node-version: "lts/*"
4545
cache: 'npm'
46-
- name: install dependencies
46+
- name: Install node dependencies
4747
run: npm ci
48-
- name: run tests
48+
- name: Run tests
4949
run: npm test
5050
deploy_dev:
5151
needs:
@@ -55,15 +55,15 @@ jobs:
5555
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
5656
with:
5757
APP_NAME: ${{ vars.APP_NAME_DEV }}
58-
DB_NAME: ${{ vars.DB_NAME_DEV }}
59-
NEW_RELIC_APP_NAME:
60-
ORGANIZATION_NAME: gsa-opp-analytics
61-
SPACE_NAME: analytics-dev
58+
CF_ORGANIZATION_NAME: ${{ vars.CF_ORGANIZATION_NAME }}
59+
CF_SPACE_NAME: ${{ vars.CF_SPACE_NAME_DEV }}
60+
DB_SERVICE_NAME: ${{ vars.DB_SERVICE_NAME_DEV }}
61+
NEW_RELIC_APP_NAME: ${{ vars.NEW_RELIC_APP_NAME_DEV }}
6262
secrets:
63+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_DEV }}
6364
CF_USERNAME: ${{ secrets.CF_USERNAME_DEV }}
6465
CF_PASSWORD: ${{ secrets.CF_PASSWORD_DEV }}
65-
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_DEV }}
66-
NEW_RELIC_LICENSE_KEY:
66+
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY_DEV }}
6767
deploy_stg:
6868
needs:
6969
- lint
@@ -72,15 +72,15 @@ jobs:
7272
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
7373
with:
7474
APP_NAME: ${{ vars.APP_NAME_STG }}
75-
DB_NAME: ${{ vars.DB_NAME_STG }}
76-
NEW_RELIC_APP_NAME:
77-
ORGANIZATION_NAME: gsa-opp-analytics
78-
SPACE_NAME: analytics-staging
75+
CF_ORGANIZATION_NAME: ${{ vars.CF_ORGANIZATION_NAME }}
76+
CF_SPACE_NAME: ${{ vars.CF_SPACE_NAME_STG }}
77+
DB_SERVICE_NAME: ${{ vars.DB_SERVICE_NAME_STG }}
78+
NEW_RELIC_APP_NAME: ${{ vars.NEW_RELIC_APP_NAME_STG }}
7979
secrets:
80+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_STG }}
8081
CF_USERNAME: ${{ secrets.CF_USERNAME_STG }}
8182
CF_PASSWORD: ${{ secrets.CF_PASSWORD_STG }}
82-
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_STG }}
83-
NEW_RELIC_LICENSE_KEY:
83+
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY_STG }}
8484
deploy_prd:
8585
needs:
8686
- lint
@@ -89,12 +89,12 @@ jobs:
8989
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
9090
with:
9191
APP_NAME: ${{ vars.APP_NAME_PRD }}
92-
DB_NAME: ${{ vars.DB_NAME_PRD }}
92+
CF_ORGANIZATION_NAME: ${{ vars.CF_ORGANIZATION_NAME }}
93+
CF_SPACE_NAME: ${{ vars.CF_SPACE_NAME_PRD }}
94+
DB_SERVICE_NAME: ${{ vars.DB_SERVICE_NAME_PRD }}
9395
NEW_RELIC_APP_NAME: ${{ vars.NEW_RELIC_APP_NAME_PRD }}
94-
ORGANIZATION_NAME: gsa-opp-analytics
95-
SPACE_NAME: analytics-production
9696
secrets:
97+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_PRD }}
9798
CF_USERNAME: ${{ secrets.CF_USERNAME_PRD }}
9899
CF_PASSWORD: ${{ secrets.CF_PASSWORD_PRD }}
99-
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_PRD }}
100100
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY_PRD }}

.github/workflows/deploy.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,71 @@ on:
44
APP_NAME:
55
required: true
66
type: string
7-
DB_NAME:
7+
CF_ORGANIZATION_NAME:
88
required: true
99
type: string
10-
NEW_RELIC_APP_NAME:
11-
type: string
12-
ORGANIZATION_NAME:
10+
CF_SPACE_NAME:
1311
required: true
1412
type: string
15-
SPACE_NAME:
13+
DB_SERVICE_NAME:
1614
required: true
1715
type: string
16+
NEW_RELIC_APP_NAME:
17+
type: string
1818
secrets:
19+
API_DATA_GOV_SECRET:
20+
required: true
1921
CF_USERNAME:
2022
required: true
2123
CF_PASSWORD:
2224
required: true
23-
API_DATA_GOV_SECRET:
24-
required: true
2525
NEW_RELIC_LICENSE_KEY:
2626

2727
env:
28+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET }}
2829
APP_NAME: ${{ inputs.APP_NAME }}
29-
DB_NAME: ${{ inputs.DB_NAME }}
30-
NEW_RELIC_APP_NAME: ${{ inputs.NEW_RELIC_APP_NAME }}
31-
ORGANIZATION_NAME: ${{ inputs.ORGANIZATION_NAME }}
32-
SPACE_NAME: ${{ inputs.SPACE_NAME }}
30+
DB_SERVICE_NAME: ${{ inputs.DB_SERVICE_NAME }}
3331
CF_USERNAME: ${{ secrets.CF_USERNAME }}
3432
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
35-
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET }}
33+
CF_ORGANIZATION_NAME: ${{ inputs.CF_ORGANIZATION_NAME }}
34+
CF_SPACE_NAME: ${{ inputs.CF_SPACE_NAME }}
35+
NEW_RELIC_APP_NAME: ${{ inputs.NEW_RELIC_APP_NAME }}
3636
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }}
3737

3838
jobs:
3939
deploy_api:
4040
runs-on: ubuntu-latest
4141
steps:
42-
- name: Code Checkout
42+
- name: Code checkout
4343
uses: actions/checkout@v4
44-
- name: Install Node
44+
- name: Install node
4545
uses: actions/setup-node@v4
4646
with:
4747
node-version: "lts/*"
4848
cache: 'npm'
49-
- name: install dependencies
49+
- name: Install node dependencies
5050
run: npm ci
51-
- name: Replace env vars in manifest.yml file
51+
- name: Install cloud foundry CLI for interacting with cloud.gov
52+
run: |
53+
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'
54+
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
55+
- name: Run envsubst on manifest.yml to set environment specific values
5256
run: |
53-
sudo apt-get update
54-
sudo apt-get install gettext
5557
mv manifest.yml manifest.yml.src
5658
envsubst < manifest.yml.src > manifest.yml
59+
cat manifest.yml
5760
- name: Replace config.js and knexfile.js with .cloudgov versions of those files
5861
run: |
5962
rm ./src/config.js
6063
mv ./src/config.js.cloudgov ./src/config.js
6164
rm knexfile.js
6265
mv knexfile.js.cloudgov knexfile.js
63-
- name: Install CF CLI
64-
run: |
65-
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'
66-
sudo dpkg -i cf8-cli-installer_8.7.4_x86-64.deb
6766
- name: Login to cloud.gov and deploy
6867
run: |
6968
set -e
7069
# Log into cloud.gov
7170
cf api api.fr.cloud.gov
72-
cf login -u $CF_USERNAME -p $CF_PASSWORD -o $ORGANIZATION_NAME -s $SPACE_NAME
73-
cat manifest.yml
71+
cf login -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORGANIZATION_NAME -s $CF_SPACE_NAME
7472
cf push -f "./manifest.yml" --no-start
7573
cf set-env $APP_NAME API_DATA_GOV_SECRET "$API_DATA_GOV_SECRET"
7674
cf restage $APP_NAME

knexfile.js.cloudgov

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22
const VCAP_SERVICES_JSON = JSON.parse(process.env.VCAP_SERVICES);
33

44
module.exports = {
5-
development: {
6-
client: 'postgresql',
7-
connection: {
8-
database: 'analytics-reporter'
9-
}
10-
},
115
production: {
126
client: 'postgresql',
137
connection: {
14-
host : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["host"],
15-
user : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["username"],
16-
password : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["password"],
17-
database : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["db_name"],
8+
host : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["host"],
9+
user : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["username"],
10+
password : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["password"],
11+
database : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["db_name"],
1812
port: 5432,
1913
ssl : true
2014
},
@@ -25,15 +19,5 @@ module.exports = {
2519
migrations: {
2620
tableName: 'knex_migrations'
2721
}
28-
},
29-
test: {
30-
client: 'postgresql',
31-
connection: {
32-
user: process.env.CIRCLECI ? 'postgres' : undefined,
33-
database: 'analytics-api-test'
34-
},
35-
migrations: {
36-
tableName: 'knex_migrations'
37-
}
3822
}
3923
};

manifest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ applications:
33
instances: 1
44
memory: 128M
55
buildpacks:
6-
- nodejs_buildpack
6+
- nodejs_buildpack
77
command: "chmod +x ./entrypoint.sh && ./entrypoint.sh"
88
services:
9-
- ${DB_NAME}
9+
- ${DB_SERVICE_NAME}
1010
stack: cflinuxfs4
1111
env:
1212
API_DATA_GOV_SECRET: ${API_DATA_GOV_SECRET}

src/config.js.cloudgov

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ module.exports = {
55
api_data_gov_secret: process.env.API_DATA_GOV_SECRET,
66
port: process.env.PORT || 4444,
77
postgres: {
8-
host : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["host"],
9-
user : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["username"],
10-
password : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["password"],
11-
database : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["db_name"],
8+
host : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["host"],
9+
user : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["username"],
10+
password : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["password"],
11+
database : VCAP_SERVICES_JSON["aws-rds"][0]["credentials"]["db_name"],
1212
port: 5432,
1313
ssl : true
1414
},

0 commit comments

Comments
 (0)