mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-06-26 00:50:49 +00:00
Try fixing CI.
This commit is contained in:
parent
13da6f9b28
commit
30e838f6c5
6
.github/workflows/general.yml
vendored
6
.github/workflows/general.yml
vendored
|
@ -32,10 +32,14 @@ jobs:
|
|||
toolchain: stable
|
||||
override: true
|
||||
- name: Migrate database
|
||||
env:
|
||||
# Weird networking issue in GitHub actions... It fails with 'connection refused' if we use 'localhost'.
|
||||
POSTGRES_HOST: postgres
|
||||
SKIP_DOCKER: true
|
||||
run: |
|
||||
sudo apt-get install libpq-dev -y
|
||||
cargo install --version=0.2.0 sqlx-cli --no-default-features --features postgres
|
||||
SKIP_DOCKER=true ./scripts/init_db.sh
|
||||
./scripts/init_db.sh
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
|
|
@ -10,6 +10,8 @@ DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
|
|||
DB_NAME="${POSTGRES_DB:=newsletter}"
|
||||
# Check if a custom port has been set, otherwise default to '5432'
|
||||
DB_PORT="${POSTGRES_PORT:=5432}"
|
||||
# Check if a custom host has been set, otherwise default to 'localhost'
|
||||
DB_HOST="${POSTGRES_HOST:=localhost}"
|
||||
|
||||
# Allow to skip Docker if a dockerized Postgres database is already running
|
||||
if [[ -z "${SKIP_DOCKER}" ]]
|
||||
|
@ -26,7 +28,7 @@ then
|
|||
fi
|
||||
|
||||
# Keep pinging Postgres until it's ready to accept commands
|
||||
until PGPASSWORD="${DB_PASSWORD}" psql -h "localhost" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; do
|
||||
until PGPASSWORD="${DB_PASSWORD}" psql -h "${DB_HOST}" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; do
|
||||
>&2 echo "Postgres is still unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue