ci: fix test_docker.sh failing due to empty .env (#12876)

This commit is contained in:
Marc 'risson' Schmitt
2025-01-29 18:23:32 +01:00
committed by GitHub
parent e41d86bd2a
commit de1bb03619

View File

@ -1,11 +1,18 @@
#!/bin/bash
set -e -x -o pipefail
hash=$(git rev-parse HEAD || openssl rand -base64 36)
hash="$(git rev-parse HEAD || openssl rand -base64 36)"
export PG_PASS=$(openssl rand -base64 36 | tr -d '\n')
export AUTHENTIK_SECRET_KEY=$(openssl rand -base64 60 | tr -d '\n')
export AUTHENTIK_IMAGE="xghcr.io/goauthentik/server"
export AUTHENTIK_TAG=$(echo $hash | cut -c1-15)
AUTHENTIK_TAG="$(echo "$hash" | cut -c1-15)" >.env
if [ -f .env ]; then
echo "Existing .env file, aborting"
exit 1
fi
echo PG_PASS="$(openssl rand -base64 36 | tr -d '\n')" >.env
echo AUTHENTIK_SECRET_KEY="$(openssl rand -base64 60 | tr -d '\n')" >>.env
echo AUTHENTIK_IMAGE="xghcr.io/goauthentik/server" >>.env
echo AUTHENTIK_TAG="${AUTHENTIK_TAG}" >>.env
export COMPOSE_PROJECT_NAME="authentik-test-${AUTHENTIK_TAG}"
# Ensure buildx is installed
@ -14,7 +21,7 @@ docker buildx install
mkdir -p ./gen-ts-api
touch .env
docker build -t ${AUTHENTIK_IMAGE}:${AUTHENTIK_TAG} .
docker build -t "${AUTHENTIK_IMAGE}:${AUTHENTIK_TAG}" .
docker compose up --no-start
docker compose start postgresql redis
docker compose run -u root server test-all