Failing to connect to a postgres service

I’ve written a simple action that runs tests in a docker container. 

Sometimes users of the action will want to be able to connect to a database for the tests. I’ve tried this and it doesn’t work, does anyone know why?

name: On Prs
on: [pull_request]

jobs:
  run_tests:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:11-alpine
        env:
          POSTGRES_USER: monster
          POSTGRES_PASSWORD: monster
        ports:
          - "54321:5432"
        # needed because the postgres container does not provide a healthcheck
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 10

    steps:
      - uses: actions/checkout@v2
      - name: "run dem tests"
        uses: Adzz/elixir_run_tests_action@v2.0.0

My app is configured correctly to listen to the correct port 54321 and it has a db password and user of monster.

Is there something obvious I am missing?

@adzz  I found your another ticket with the same question in more detail: https://github.community/t5/GitHub-Actions/Can-t-connect-to-Postgres-service/m-p/51301 

Please follow on that one. Thank you for your understanding. 

1 Like