-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cf11d0
commit 78e20c4
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,7 +337,12 @@ jobs: | |
- name: Checkout code | ||
uses: actions/[email protected] | ||
- name: Setup postgres | ||
uses: actions/setup-postgres | ||
uses: ../../actions/setup-postgres | ||
- name: Setup Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: "1.22.6" | ||
check-latest: true | ||
- name: Setup DB | ||
run: | | ||
# Build binary | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Setup Postgresql | ||
description: Setup postgres docker container via docker-compose, allowing usage of a custom command, see https://github.com/orgs/community/discussions/26688 | ||
inputs: | ||
base-path: | ||
description: Path to the base of the repo | ||
required: false | ||
default: . | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Start postgres service | ||
run: docker compose up -d | ||
shell: bash | ||
working-directory: ${{ inputs.base-path }}/actions/setup-postgres | ||
- name: Wait for postgres service to be healthy | ||
run: ./wait-for-healthy-postgres.sh | ||
shell: bash | ||
working-directory: ${{ inputs.base-path }}/actions/setup-postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: gha_postgres | ||
services: | ||
postgres: | ||
ports: | ||
- "5432:5432" | ||
container_name: cl_pg | ||
image: postgres:14-alpine | ||
command: postgres ${POSTGRES_OPTIONS} | ||
env_file: | ||
- .env | ||
healthcheck: | ||
test: "pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}" | ||
interval: 2s | ||
timeout: 5s | ||
retries: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
RETRIES=10 | ||
|
||
until [ $RETRIES -eq 0 ]; do | ||
DOCKER_OUTPUT=$(docker compose ps postgres --status running --format json) | ||
JSON_TYPE=$(echo "$DOCKER_OUTPUT" | jq -r 'type') | ||
|
||
if [ "$JSON_TYPE" == "array" ]; then | ||
HEALTH_STATUS=$(echo "$DOCKER_OUTPUT" | jq -r '.[0].Health') | ||
elif [ "$JSON_TYPE" == "object" ]; then | ||
HEALTH_STATUS=$(echo "$DOCKER_OUTPUT" | jq -r '.Health') | ||
else | ||
HEALTH_STATUS="Unknown JSON type: $JSON_TYPE" | ||
fi | ||
|
||
echo "postgres health status: $HEALTH_STATUS" | ||
if [ "$HEALTH_STATUS" == "healthy" ]; then | ||
exit 0 | ||
fi | ||
|
||
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..." | ||
sleep 2 | ||
done | ||
|
||
exit 1 |