Skip to content

Commit

Permalink
Draft: attach redis
Browse files Browse the repository at this point in the history
  • Loading branch information
JargeZ committed Aug 21, 2024
1 parent 2815f0b commit 6fa0a1a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -79,6 +80,16 @@ 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'" /dev/null | grep -o "redis://.*")
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"
Expand Down

0 comments on commit 6fa0a1a

Please sign in to comment.