From e1198c376961ab6ac44b8841b6270b4d15fee6d7 Mon Sep 17 00:00:00 2001 From: Joppe De Cuyper Date: Wed, 16 Jul 2025 08:19:24 +0200 Subject: [PATCH] Add custom branch option --- README.md | 12 ++++++++---- action.yaml | 7 ++++++- index.js | 7 +++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7f62e8e..2c02e4c 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ # `deploy all`. # Required. dep: deploy - + # The path to the PHP binary to use. # Optional. php-binary: "php" @@ -26,7 +26,7 @@ # Specifies a sub directory within the repository to deploy # Optional sub-directory: "..." - + # Config options for the Deployer. Same as the `-o` flag in the CLI. # Optional. options: @@ -50,13 +50,13 @@ # Optional. ssh-config: | ... - + # Option to skip over the SSH setup/configuration. # Self-hosted runners don't need the SSH configuration or the SSH agent # to be started. # Optional. skip-ssh-setup: false - + # Deployer version to download from deployer.org. # First, the action will check for Deployer binary at those paths: # - `vendor/bin/deployer.phar` @@ -78,6 +78,10 @@ # You can specify the output verbosity level. # Optional. Defaults to -v. verbosity: -vvv + + # The branch to deploy. Adds --branch=value to the deploy command. + # Optional. + branch: "main" ``` ## Example diff --git a/action.yaml b/action.yaml index f69e11f..19e595e 100644 --- a/action.yaml +++ b/action.yaml @@ -7,7 +7,7 @@ inputs: dep: required: true description: The command. - + php-binary: required: false default: '' @@ -68,6 +68,11 @@ inputs: default: '-v' description: Verbosity level Can be -v, -vv or -vvv. + branch: + required: false + default: '' + description: The branch to deploy. + runs: using: 'node20' main: 'index.js' diff --git a/index.js b/index.js index b50cc0b..f2b88a6 100644 --- a/index.js +++ b/index.js @@ -124,15 +124,18 @@ async function dep() { } catch (e) { console.error('Invalid JSON in options') } - + let phpBin = 'php' let phpBinArg = core.getInput('php-binary'); if (phpBinArg !== '') { phpBin = phpBinArg } + let branch = core.getInput('branch') + let branchOption = branch !== '' ? `--branch=${branch}` : '' + try { - await $`${phpBin} ${dep} ${cmd} ${recipe} --no-interaction ${ansi} ${verbosity} ${options}` + await $`${phpBin} ${dep} ${cmd} ${recipe} --no-interaction ${ansi} ${verbosity} ${options} ${branchOption}` } catch (err) { core.setFailed(`Failed: dep ${cmd}`) }