-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): Run db migrations in CI task container with SSL #4354
- Loading branch information
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,4 @@ blob-report/ | |
playwright/.cache/ | ||
playwright/.auth/* | ||
!playwright/.auth/.gitkeep | ||
database.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
platform: linux | ||
inputs: [name: src] | ||
outputs: [name: src] | ||
run: | ||
dir: src | ||
path: bash | ||
args: | ||
- -c | ||
- node --env-file=.env ./ci/tasks/configure-database-migrations.js | ||
- node node_modules/.bin/db-migrate up --config database.json -e production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const fs = require('node:fs'); | ||
const cfenv = require('cfenv'); | ||
|
||
const { APP_ENV } = process.env; | ||
const fileName = 'database.json'; | ||
|
||
const baseConfig = { | ||
driver: 'pg', | ||
port: '5432', | ||
ssl: { | ||
rejectUnauthorized: false, | ||
}, | ||
schema: 'public', | ||
}; | ||
|
||
function main() { | ||
try { | ||
const appEnv = cfenv.getAppEnv(); | ||
const creds = appEnv.getServiceCreds(`federalist-${APP_ENV}-rds`); | ||
|
||
const config = { | ||
production: { | ||
...baseConfig, | ||
user: creds.username, | ||
password: creds.password, | ||
host: creds.host, | ||
database: creds.name, | ||
port: creds.port, | ||
}, | ||
}; | ||
|
||
const data = JSON.stringify(config); | ||
|
||
fs.writeFileSync(fileName, data); | ||
|
||
console.log('\n\nCreated database configuration.\n\n'); | ||
|
||
process.exit(0); | ||
} catch (error) { | ||
console.error('\n\n!!! ERROR CONFIGURING DATABASE MIGRATIONS !!!\n\n'); | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |