Files
grecia/.github/workflows/db_schema.yml
Javi Martín 1c68ad3a2a Use a maintained PostgreSQL version in Docker
We're using version 13 because it's the one included in Debian Bullseye,
which is the operating system we currently use in our Dockerfile.

For consistency, we're using the same version in GitHub Actions.

Note this image requires setting a password. Otherwise we get an error:

> Database is uninitialized and superuser password is not specified.
> You must specify POSTGRES_PASSWORD to a non-empty value for the
> superuser. For example, "-e POSTGRES_PASSWORD=password" on
> "docker run".

Since now we're setting a password in the postgres service, we also need
to provide the `PGPASSWORD` environment variable (or to specify the
password in the `database.yml` file, which we do for GitLab since it
uses a separate database configuration file). Otherwise we get an error:

```
PG::ConnectionBad: connection to server at "::1", port 5432 failed:
fe_sendauth: no password supplied (PG::ConnectionBad)
```
2024-09-18 15:44:50 +02:00

40 lines
1.0 KiB
YAML

name: schema
on:
push:
branches:
- master
pull_request:
branches-ignore:
- i18n_master
permissions:
contents: read
jobs:
schema:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13.16
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_USER: consul
POSTGRES_PASSWORD: password
env:
PGUSER: consul
PGPASSWORD: password
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Copy secrets and database files
run: for i in config/*.example; do cp "$i" "${i/.example}"; done
- name: Backup schema file
run: cp db/schema.rb db/commited_schema.rb
- name: Setup database
run: bundle exec rake db:create db:migrate
- name: Check the commited schema is correct
run: diff db/schema.rb db/commited_schema.rb