Skip to content

Commit

Permalink
ci: configure postgres via custom service 2
Browse files Browse the repository at this point in the history
  • Loading branch information
r1tsuu committed Nov 8, 2024
1 parent d942d8c commit 807df29
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ jobs:
AWS_SECRET_ACCESS_KEY: localstack
AWS_REGION: us-east-1

services:
postgres:
image: ${{ (startsWith(matrix.database, 'postgres') ) && 'postgis/postgis:16-3.4' || '' }}
env:
# must specify password for PG Docker container image, see: https://registry.hub.docker.com/_/postgres?tab=description&page=1&name=10
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -232,14 +245,14 @@ jobs:
- name: Start LocalStack
run: pnpm docker:start

- name: Start PostgreSQL
uses: CasperWA/[email protected]
with:
postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
postgresql db: ${{ env.POSTGRES_DB }}
postgresql user: ${{ env.POSTGRES_USER }}
postgresql password: ${{ env.POSTGRES_PASSWORD }}
if: startsWith(matrix.database, 'postgres')
# - name: Start PostgreSQL
# uses: CasperWA/[email protected]
# with:
# postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
# postgresql db: ${{ env.POSTGRES_DB }}
# postgresql user: ${{ env.POSTGRES_USER }}
# postgresql password: ${{ env.POSTGRES_PASSWORD }}
# if: startsWith(matrix.database, 'postgres')

- name: Install Supabase CLI
uses: supabase/setup-cli@v1
Expand All @@ -262,7 +275,6 @@ jobs:
psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "CREATE ROLE runner SUPERUSER LOGIN;"
psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "SELECT version();"
echo "POSTGRES_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" >> $GITHUB_ENV
sudo apt-get install -y postgis postgresql-14-postgis-3-scripts
if: startsWith(matrix.database, 'postgres')

- name: Configure PostgreSQL with custom schema
Expand Down

0 comments on commit 807df29

Please sign in to comment.