From 307c70fb0e47e965c38bcbb9a1bb78b0b0856f7b Mon Sep 17 00:00:00 2001 From: Chris Patterson Date: Thu, 15 Aug 2019 14:41:02 -0400 Subject: [PATCH] moved host and port to env --- .github/workflows/postgres-service.yml | 8 ++++++++ postgres/client.js | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/postgres-service.yml b/.github/workflows/postgres-service.yml index 691bde8..6c769e6 100644 --- a/.github/workflows/postgres-service.yml +++ b/.github/workflows/postgres-service.yml @@ -4,6 +4,9 @@ jobs: build: runs-on: ubuntu-latest + container: + image: node:10.16-jessie + services: postgres: image: postgres:10.8 @@ -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] }} diff --git a/postgres/client.js b/postgres/client.js index 7f50bb3..7385df7 100644 --- a/postgres/client.js +++ b/postgres/client.js @@ -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'