Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
moved host and port to env
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispat committed Aug 15, 2019
1 parent 2b428d3 commit 307c70f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/postgres-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ jobs:
build:
runs-on: ubuntu-latest

container:
image: node:10.16-jessie

services:
postgres:
image: postgres:10.8
Expand All @@ -27,3 +30,8 @@ jobs:
working-directory: ./postgres
- run: node client.js
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] }}
6 changes: 3 additions & 3 deletions postgres/client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { Client } = require('pg')
const { Client } = require('pg');

const pgclient = new Client({
host: 'postgres',
port: 5432,
host: process.env.POSTGRES_HOST,
port: process.env.POSTGRES_PORT,
user: 'postgres',
password: 'postgres',
database: 'postgres'
Expand Down

0 comments on commit 307c70f

Please sign in to comment.