Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions .github/workflows/fly-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
fi

APP_FROM_CONFIG="$(sed -n 's/^app = \"\\(.*\\)\"/\\1/p' fly.toml | head -n1)"
APP_NAME="${FLY_APP_NAME:-${APP_FROM_CONFIG}}"
APP_NAME="${APP_FROM_CONFIG:-${FLY_APP_NAME}}"
PRIMARY_REGION="${FLY_PRIMARY_REGION:-ord}"
VOLUME_NAME="${FLY_VOLUME_NAME:-yappybara_data}"
VOLUME_SIZE_GB="${FLY_VOLUME_SIZE_GB:-1}"
Expand All @@ -55,18 +55,20 @@ jobs:
exit 1
fi

# Recover from stale repo variable values by falling back to fly.toml app.
if ! flyctl apps info --app "${APP_NAME}" > /dev/null 2>&1 \
&& [ -n "${APP_FROM_CONFIG}" ] \
&& [ "${APP_FROM_CONFIG}" != "${APP_NAME}" ] \
&& flyctl apps info --app "${APP_FROM_CONFIG}" > /dev/null 2>&1; then
echo "Configured FLY_APP_NAME '${APP_NAME}' not found; using fly.toml app '${APP_FROM_CONFIG}'."
APP_NAME="${APP_FROM_CONFIG}"
if [ -n "${APP_FROM_CONFIG}" ] && [ -n "${FLY_APP_NAME}" ] && [ "${APP_FROM_CONFIG}" != "${FLY_APP_NAME}" ]; then
echo "Ignoring stale FLY_APP_NAME='${FLY_APP_NAME}' and using fly.toml app '${APP_FROM_CONFIG}'."
fi

if ! flyctl apps info --app "${APP_NAME}" > /dev/null 2>&1; then
echo "Fly app ${APP_NAME} does not exist yet. Creating it now..."
flyctl apps create "${APP_NAME}"
APP_INFO_OUTPUT="$(flyctl apps info --app "${APP_NAME}" 2>&1 || true)"
if ! echo "${APP_INFO_OUTPUT}" | grep -q "Hostname"; then
if echo "${APP_INFO_OUTPUT}" | grep -qi "app not found"; then
echo "Fly app ${APP_NAME} does not exist yet. Creating it now..."
flyctl apps create "${APP_NAME}"
else
echo "${APP_INFO_OUTPUT}"
echo "Unable to access Fly app '${APP_NAME}'. Check that FLY_API_TOKEN has deploy access to this app."
exit 1
fi
fi

if ! flyctl volumes list --app "${APP_NAME}" | grep -q "${VOLUME_NAME}"; then
Expand Down