PostgreSQL 12 on GitHub Actions

Currently I’m using postgres 11 like this:

    services:
      postgres:
        image: postgres:11.5
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

I would like to use postgres 12, however when I change it to:

    services:
      postgres:
        image: postgres:12.2
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

The container cannot be stared as it errors out with:

unhealthy
##[error]Failed to initialize, postgres service is unhealthy.

Anyone knows how to properly use postgres 12 on GH Actions?

@morgoth,

I can reproduce the same problem on my side when using the postgres image to set service container on the job.
I also tested some other supported tags of the postgres image from the Docker Hub, and I found that all them have the same problem.
It seems that only the tag 11.5 of the postgres image can work.

It is strange that when I tried using the postgres image to set a container (not service container) on the job, all the tags of the image can work fine.

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    container: 
      image: postgres:12.2
      ports: 
        - 5432:5432
      options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
    steps:
      . . .

I have created an internal issue ticket to report this problem to the appropriate engineering team for further investigation and evaluation. If they have any progress, I will notify you in time, and sometimes the appropriate engineers may directly reply you here.

1 Like

@brightran Thanks for checking.

I’m not sure what are the differences in using “services” vs “container” but now I have issues with other steps:

Run ruby/setup-ruby@v1
 with:
   ruby-version: default
   bundler: default
   bundler-cache: false
   working-directory: .
/usr/bin/docker exec  d89ff40a66b2ab498d7d68272c1363cc966750185403d7fd06dd715edf779ef5 sh -c "cat /etc/*release | grep ^ID"
##[error]ENOENT: no such file or directory, open '/etc/lsb-release'

The beginning of my template is quite generic:

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    container:
      image: postgres:12.2
      ports: ["5432:5432"]
      options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
    - uses: actions/checkout@v2

    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
....

If you use container instead of services your build will run inside that container. Presumably the postgres container doesn’t have the LSB files (why would it need them?), but the setup-ruby action needs them and fails.

fwiw I tried postgres 11.5 and am getting the same error still (steps running on vm, not in a container)