moved host and port to env
This commit is contained in:
8
.github/workflows/postgres-service.yml
vendored
8
.github/workflows/postgres-service.yml
vendored
@@ -4,6 +4,9 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
container:
|
||||||
|
image: node:10.16-jessie
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:10.8
|
image: postgres:10.8
|
||||||
@@ -27,3 +30,8 @@ jobs:
|
|||||||
working-directory: ./postgres
|
working-directory: ./postgres
|
||||||
- run: node client.js
|
- run: node client.js
|
||||||
working-directory: ./postgres
|
working-directory: ./postgres
|
||||||
|
env:
|
||||||
|
# use postgres for the host here because we have specified a contaienr for the job.
|
||||||
|
# If we were running the job on the VM this would be localhost
|
||||||
|
POSTGRES_HOST: postgres
|
||||||
|
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const { Client } = require('pg')
|
const { Client } = require('pg');
|
||||||
|
|
||||||
const pgclient = new Client({
|
const pgclient = new Client({
|
||||||
host: 'postgres',
|
host: process.env.POSTGRES_HOST,
|
||||||
port: 5432,
|
port: process.env.POSTGRES_PORT,
|
||||||
user: 'postgres',
|
user: 'postgres',
|
||||||
password: 'postgres',
|
password: 'postgres',
|
||||||
database: 'postgres'
|
database: 'postgres'
|
||||||
|
|||||||
Reference in New Issue
Block a user