Skip to content

Instantly share code, notes, and snippets.

@asolera
Created November 4, 2020 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolera/4409dd056415af0278457d19beb0f6f2 to your computer and use it in GitHub Desktop.
Save asolera/4409dd056415af0278457d19beb0f6f2 to your computer and use it in GitHub Desktop.
Calling PostgreSQL script from GitLab CI
# Credentials must be passed in through environment variables (DB_HOST, DB_PORT, DB_USER, DB_PASS, DB_NAME)
variables:
DOCKER_DRIVER: overlay2
GIT_STRATEGY: fetch
PGPASSWORD: "$DB_PASS"
services:
- docker:19.03.8-dind
stages:
- example
job:
stage: example
image: alpine:3.12
before_script:
- apk add --no-cache postgresql-client
script:
- psql -U $DB_USER -h $DB_HOST -d $DB_NAME -p $DB_PORT -a -f script.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment