diff --git a/Dockerfile b/Dockerfile index 6371b33..d18b2f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine -RUN apk add --no-cache curl jq +RUN apk add --no-cache curl jq util-linux RUN curl -L https://fly.io/install.sh | FLYCTL_INSTALL=/usr/local sh diff --git a/action.yml b/action.yml index e220531..696314d 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,9 @@ inputs: description: path to a directory containing a fly.toml to clone postgres: description: Optionally attach the app to a pre-existing Postgres cluster on Fly + redis: + description: Optionally create a new Redis cluster on Fly and attach it to the app (Will destroy automatically) + default: false secrets: description: Secrets to be set on the app. Separate multiple secrets with a space vmsize: diff --git a/entrypoint.sh b/entrypoint.sh index 7106c2d..1a75f21 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -39,6 +39,7 @@ fi # PR was closed - remove the Fly app if one exists and exit. if [ "$EVENT_TYPE" = "closed" ]; then flyctl apps destroy "$app" -y || true + flyctl redis destroy "redis-preview-$app" -y || true exit 0 fi @@ -79,6 +80,17 @@ if [ -n "$INPUT_POSTGRES" ]; then flyctl postgres attach "$INPUT_POSTGRES" --app "$app" || true fi +# Create a Redis instance if requested. +if [ "$INPUT_REDIS" == "true" ]; then + # TODO: issue + # Error: regions codes must be specified in a comma-separated when not running interactively + REDIS_URL=$(script -q -c 'flyctl redis create --enable-eviction --name "redis-preview-"'$app'" --region "'$region'" --org "'$org'"' .tmp-out | grep -o "redis://.*") + cat .tmp-out + if [ -n "$REDIS_URL" ]; then + flyctl secrets set "REDIS_URL"="$REDIS_URL" --app "$app" + fi +fi + # Use remote builders if [ -n "$INPUT_REMOTE_ONLY" ]; then remote_only="--remote-only"