diff --git a/README.md b/README.md index 1f697a8..e314f8a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,10 @@ # `deploy all`. # Required. dep: deploy + + # 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. diff --git a/action.yaml b/action.yaml index 2e07c45..74aadcb 100644 --- a/action.yaml +++ b/action.yaml @@ -8,6 +8,11 @@ inputs: required: true description: The command. + sub-directory: + required: false + default: '' + description: Specifies a sub directory within the repository to deploy. + options: required: false default: '' diff --git a/index.js b/index.js index c7c7456..c87cad6 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ import core from '@actions/core' -import { $, fs } from 'zx' +import { $, fs, cd } from 'zx' void async function main() { try { @@ -52,6 +52,11 @@ async function ssh() { async function dep() { let dep = core.getInput('deployer-binary') + let subDirectory = core.getInput('sub-directory').trim() + + if (subDirectory !== '') { + cd(subDirectory) + } if (dep === '') for (let c of ['vendor/bin/deployer.phar', 'vendor/bin/dep', 'deployer.phar']) { @@ -69,15 +74,15 @@ async function dep() { if (lock['packages']) { version = lock['packages'] .find(p => p.name === 'deployer/deployer') - .version + ?.version } - if (version === '' && lock['packages-dev']) { + if ((version === '' || typeof version === 'undefined') && lock['packages-dev']) { version = lock['packages-dev'] .find(p => p.name === 'deployer/deployer') - .version + ?.version } } - if (version === '') { + if (version === '' || typeof version === 'undefined') { throw new Error('Deployer binary not found. Please specify deployer-binary or deployer-version.') } version = version.replace(/^v/, '')