mirror of
https://github.com/deployphp/action.git
synced 2024-11-23 12:29:03 +00:00
Sub-directories support (#58)
* Add support to subdirectories * Update sub-directory description * Import cd function * Improve version checkings * Improve version checking
This commit is contained in:
parent
e71b9feeeb
commit
b4aad0389b
@ -19,6 +19,10 @@
|
|||||||
# Required.
|
# Required.
|
||||||
dep: deploy
|
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.
|
# Config options for the Deployer. Same as the `-o` flag in the CLI.
|
||||||
# Optional.
|
# Optional.
|
||||||
options:
|
options:
|
||||||
|
@ -8,6 +8,11 @@ inputs:
|
|||||||
required: true
|
required: true
|
||||||
description: The command.
|
description: The command.
|
||||||
|
|
||||||
|
sub-directory:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: Specifies a sub directory within the repository to deploy.
|
||||||
|
|
||||||
options:
|
options:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
15
index.js
15
index.js
@ -1,5 +1,5 @@
|
|||||||
import core from '@actions/core'
|
import core from '@actions/core'
|
||||||
import { $, fs } from 'zx'
|
import { $, fs, cd } from 'zx'
|
||||||
|
|
||||||
void async function main() {
|
void async function main() {
|
||||||
try {
|
try {
|
||||||
@ -52,6 +52,11 @@ async function ssh() {
|
|||||||
|
|
||||||
async function dep() {
|
async function dep() {
|
||||||
let dep = core.getInput('deployer-binary')
|
let dep = core.getInput('deployer-binary')
|
||||||
|
let subDirectory = core.getInput('sub-directory').trim()
|
||||||
|
|
||||||
|
if (subDirectory !== '') {
|
||||||
|
cd(subDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
if (dep === '')
|
if (dep === '')
|
||||||
for (let c of ['vendor/bin/deployer.phar', 'vendor/bin/dep', 'deployer.phar']) {
|
for (let c of ['vendor/bin/deployer.phar', 'vendor/bin/dep', 'deployer.phar']) {
|
||||||
@ -69,15 +74,15 @@ async function dep() {
|
|||||||
if (lock['packages']) {
|
if (lock['packages']) {
|
||||||
version = lock['packages']
|
version = lock['packages']
|
||||||
.find(p => p.name === 'deployer/deployer')
|
.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']
|
version = lock['packages-dev']
|
||||||
.find(p => p.name === 'deployer/deployer')
|
.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.')
|
throw new Error('Deployer binary not found. Please specify deployer-binary or deployer-version.')
|
||||||
}
|
}
|
||||||
version = version.replace(/^v/, '')
|
version = version.replace(/^v/, '')
|
||||||
|
Loading…
Reference in New Issue
Block a user