Skip to content

Commit

Permalink
Pass build-args
Browse files Browse the repository at this point in the history
  • Loading branch information
JargeZ committed Jul 20, 2024
1 parent 704a7e0 commit 2c6343f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@ If you have an existing `fly.toml` in your repo, this action will copy it with a

## Inputs

| name | description |
| ---------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | The name of the Fly app. Alternatively, set the env `FLY_APP`. For safety, **must include the PR number** (if not disabled by `allow_unsafe_name`). Example: `myapp-pr-${{ github.event.number }}`. Defaults to `pr-{number}-{repo_org}-{repo_name}`. |
| `image` | Optional pre-existing Docker image to use |
| `config` | Optional path to a custom Fly toml config. Config path should be relative to `path` parameter, if specified. |
| `region` | Which Fly region to run the app in. Alternatively, set the env `FLY_REGION`. Defaults to `iad`. |
| `org` | Which Fly organization to launch the app under. Alternatively, set the env `FLY_ORG`. Defaults to `personal`. |
| `path` | Path to run the `flyctl` commands from. Useful if you have an existing `fly.toml` in a subdirectory. |
| `postgres` | Optional name of an existing Postgres cluster to `flyctl postgres attach` to. |
| `update` | Whether or not to update this Fly app when the PR is updated. Default `true`. |
| `secrets` | Secrets to be set on the app. Separate multiple secrets with a space |
| `vmsize` | Set app VM to a named size, eg. shared-cpu-1x, dedicated-cpu-1x, dedicated-cpu-2x etc. Takes precedence over cpu, cpu kind, and memory inputs. |
| `cpu` | Set app VM CPU (defaults to 1 cpu). Default 1. |
| `cpukind` | Set app VM CPU kind - shared or performance. Default shared. |
| `memory` | Set app VM memory in megabytes. Default 256. |
| `ha` | Create spare machines that increases app availability. Default `false`. |
| `allow_unsafe_name` | Allow a name that does not contain a PR number. Useful for deploying preview environments across multiple repo with reusable pipelines. Default `false`. |
| name | description |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | The name of the Fly app. Alternatively, set the env `FLY_APP`. For safety, must include the PR number. Example: `myapp-pr-${{ github.event.number }}`. Defaults to `pr-{number}-{repo_org}-{repo_name}`. |
| `image` | Optional pre-existing Docker image to use |
| `config` | Optional path to a custom Fly toml config. Config path should be relative to `path` parameter, if specified. |
| `region` | Which Fly region to run the app in. Alternatively, set the env `FLY_REGION`. Defaults to `iad`. |
| `org` | Which Fly organization to launch the app under. Alternatively, set the env `FLY_ORG`. Defaults to `personal`. |
| `path` | Path to run the `flyctl` commands from. Useful if you have an existing `fly.toml` in a subdirectory. |
| `postgres` | Optional name of an existing Postgres cluster to `flyctl postgres attach` to. |
| `update` | Whether or not to update this Fly app when the PR is updated. Default `true`. |
| `secrets` | Secrets to be set on the app. Separate multiple secrets with a space |
| `vmsize` | Set app VM to a named size, eg. shared-cpu-1x, dedicated-cpu-1x, dedicated-cpu-2x etc. Takes precedence over cpu, cpu kind, and memory inputs. |
| `cpu` | Set app VM CPU (defaults to 1 cpu). Default 1. |
| `cpukind` | Set app VM CPU kind - shared or performance. Default shared. |
| `memory` | Set app VM memory in megabytes. Default 256. |
| `ha` | Create spare machines that increases app availability. Default `false`. |
| `allow_unsafe_name` | Allow a name that does not contain a PR number. Useful for deploying preview environments across multiple repo with reusable pipelines. Default `false`. |
| `build_args` | Build arguments to pass to the Docker build. Separate multiple arguments with a semicolon. `FOO=bar;BAZ=qux` |

## Required Secrets

Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ inputs:
allow_unsafe_name:
description: Allow a name that does not contain a PR number. Useful for deploying preview environments across multiple repo with reusable pipelines (default false)
default: false
build_args:
description: Build arguments to pass to the Docker build. Separate multiple arguments with a semicolon. FOO=bar;BAZ=qux
9 changes: 7 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ if [ -n "$INPUT_POSTGRES" ]; then
flyctl postgres attach "$INPUT_POSTGRES" --app "$app" || true
fi

# create --build-arg array
if [ -n "$INPUT_BUILD_ARGS" ]; then
BUILD_ARGS="--build-arg ${INPUT_BUILD_ARGS//;/ --build-arg }"
fi

# Trigger the deploy of the new version.
echo "Contents of config $config file: " && cat "$config"
if [ -n "$INPUT_VM" ]; then
flyctl deploy --config "$config" --app "$app" --regions "$region" --image "$image" --strategy immediate --ha=$INPUT_HA --vm-size "$INPUT_VMSIZE"
flyctl deploy --config "$config" --app "$app" --regions "$region" --image "$image" --strategy immediate --ha=$INPUT_HA --vm-size "$INPUT_VMSIZE" $BUILD_ARGS
else
flyctl deploy --config "$config" --app "$app" --regions "$region" --image "$image" --strategy immediate --ha=$INPUT_HA --vm-cpu-kind "$INPUT_CPUKIND" --vm-cpus $INPUT_CPU --vm-memory "$INPUT_MEMORY"
flyctl deploy --config "$config" --app "$app" --regions "$region" --image "$image" --strategy immediate --ha=$INPUT_HA --vm-cpu-kind "$INPUT_CPUKIND" --vm-cpus $INPUT_CPU --vm-memory "$INPUT_MEMORY" $BUILD_ARGS
fi

# Make some info available to the GitHub workflow.
Expand Down

0 comments on commit 2c6343f

Please sign in to comment.