From 2815f0bdccdcb85e6275cb572daaa3985a751210 Mon Sep 17 00:00:00 2001 From: JargeZ Date: Wed, 31 Jul 2024 00:04:32 +1000 Subject: [PATCH] Remote builder input argument --- README.md | 1 + action.yml | 3 +++ entrypoint.sh | 9 +++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d8a8f4b..848957a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ If you have an existing `fly.toml` in your repo, this action will copy it with a | `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`. | +| `remote_only` | Add --remote-only flag to flyctl deploy command to use remote build. Improve build speed (default false) | | `build_args` | Optional Docker --build-arg Separate multiple arguments with a space | | `build_secrets` | Optional Docker --build-secret | diff --git a/action.yml b/action.yml index f8fb2d7..e220531 100644 --- a/action.yml +++ b/action.yml @@ -41,6 +41,9 @@ 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 + remote_only: + description: Add --remote-only flag to flyctl deploy command to use remote build. Improve build speed (default false) + default: false build_args: description: Optional Docker --build-arg build_secrets: diff --git a/entrypoint.sh b/entrypoint.sh index e26d6e8..7106c2d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -79,12 +79,17 @@ if [ -n "$INPUT_POSTGRES" ]; then flyctl postgres attach "$INPUT_POSTGRES" --app "$app" || true fi +# Use remote builders +if [ -n "$INPUT_REMOTE_ONLY" ]; then + remote_only="--remote-only" +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 ${build_args} ${build_secrets} ${runtime_environment} --vm-size "$INPUT_VMSIZE" + flyctl deploy --config "$config" --app "$app" --regions "$region" --image "$image" --strategy immediate --ha=$INPUT_HA ${build_args} ${build_secrets} ${runtime_environment} ${remote_only} --vm-size "$INPUT_VMSIZE" else - flyctl deploy --config "$config" --app "$app" --regions "$region" --image "$image" --strategy immediate --ha=$INPUT_HA ${build_args} ${build_secrets} ${runtime_environment} --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 ${build_args} ${build_secrets} ${runtime_environment} ${remote_only} --vm-cpu-kind "$INPUT_CPUKIND" --vm-cpus $INPUT_CPU --vm-memory "$INPUT_MEMORY" fi # Make some info available to the GitHub workflow.