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'