mirror of
https://github.com/deployphp/action.git
synced 2024-11-23 04:19:02 +00:00
Add deployer-version
This commit is contained in:
parent
fe854546be
commit
77ac0bfc15
30
README.md
30
README.md
@ -2,42 +2,34 @@
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: deployphp/action@1
|
uses: deployphp/action@v1
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
dep: deploy all
|
dep: deploy
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
See [action.yaml](action.yaml).
|
See [action.yaml](action.yaml).
|
||||||
|
|
||||||
## Deployer version
|
|
||||||
|
|
||||||
First, the action will check for Deployer binary at those paths:
|
|
||||||
- `vendor/bin/dep`
|
|
||||||
- `deployer.phar`
|
|
||||||
|
|
||||||
If the binary not found, phar version will be downloaded from
|
|
||||||
[deployer.org](https://deployer.org/download).
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to prod
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@master
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: 7.4
|
php-version: '8.0'
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: deployphp/action@master
|
uses: deployphp/action@v1
|
||||||
with:
|
with:
|
||||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||||
known-hosts: ${{ secrets.KNOWN_HOSTS }}
|
dep: deploy
|
||||||
ssh-config: ${{ secrets.SSH_CONFIG }}
|
|
||||||
dep: deploy prod -v
|
|
||||||
```
|
```
|
||||||
|
15
action.yaml
15
action.yaml
@ -31,7 +31,20 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
description: >
|
description: >
|
||||||
The SSH configuration.
|
The SSH configuration. Content of `~/.ssh/config` file.
|
||||||
|
|
||||||
|
deployer-version:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: >
|
||||||
|
Deployer version to download from deployer.org.
|
||||||
|
|
||||||
|
First, the action will check for Deployer binary at those paths:
|
||||||
|
- `vendor/bin/dep`
|
||||||
|
- `deployer.phar`
|
||||||
|
|
||||||
|
If the binary not found, phar version will be downloaded from
|
||||||
|
[deployer.org](https://deployer.org/download).
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
30
index.js
30
index.js
@ -12,10 +12,10 @@ void async function main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
async function ssh() {
|
async function ssh() {
|
||||||
let ssh = `${process.env['HOME']}/.ssh`
|
let sshHomeDir = `${process.env['HOME']}/.ssh`
|
||||||
|
|
||||||
if (!fs.existsSync(ssh)) {
|
if (!fs.existsSync(sshHomeDir)) {
|
||||||
fs.mkdirSync(ssh)
|
fs.mkdirSync(sshHomeDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
let authSock = '/tmp/ssh-auth.sock'
|
let authSock = '/tmp/ssh-auth.sock'
|
||||||
@ -27,17 +27,17 @@ async function ssh() {
|
|||||||
|
|
||||||
const knownHosts = core.getInput('known-hosts')
|
const knownHosts = core.getInput('known-hosts')
|
||||||
if (knownHosts !== '') {
|
if (knownHosts !== '') {
|
||||||
fs.appendFileSync(`${ssh}/known_hosts`, knownHosts)
|
fs.appendFileSync(`${sshHomeDir}/known_hosts`, knownHosts)
|
||||||
fs.chmodSync(`${ssh}/known_hosts`, '600')
|
fs.chmodSync(`${sshHomeDir}/known_hosts`, '600')
|
||||||
} else {
|
} else {
|
||||||
fs.appendFileSync(`${ssh}/config`, `StrictHostKeyChecking no`)
|
fs.appendFileSync(`${sshHomeDir}/config`, `StrictHostKeyChecking no`)
|
||||||
fs.chmodSync(`${ssh}/config`, '600')
|
fs.chmodSync(`${sshHomeDir}/config`, '600')
|
||||||
}
|
}
|
||||||
|
|
||||||
const sshConfig = core.getInput('ssh-config')
|
let sshConfig = core.getInput('ssh-config')
|
||||||
if (sshConfig !== '') {
|
if (sshConfig !== '') {
|
||||||
fs.writeFileSync(`${ssh}/config`, sshConfig)
|
fs.writeFileSync(`${sshHomeDir}/config`, sshConfig)
|
||||||
fs.chmodSync(`${ssh}/config`, '600')
|
fs.chmodSync(`${sshHomeDir}/config`, '600')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,12 +51,20 @@ async function dep() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dep) {
|
if (!dep) {
|
||||||
|
let version = core.getInput('deployer-version')
|
||||||
|
if (version === '') {
|
||||||
execa.commandSync('curl -LO https://deployer.org/deployer.phar')
|
execa.commandSync('curl -LO https://deployer.org/deployer.phar')
|
||||||
|
} else {
|
||||||
|
if (!/^v/.test(version)) {
|
||||||
|
version = 'v' + version
|
||||||
|
}
|
||||||
|
execa.commandSync(`curl -LO https://deployer.org/releases/${version}/deployer.phar`)
|
||||||
|
}
|
||||||
execa.commandSync('sudo chmod +x deployer.phar')
|
execa.commandSync('sudo chmod +x deployer.phar')
|
||||||
dep = 'deployer.phar'
|
dep = 'deployer.phar'
|
||||||
}
|
}
|
||||||
|
|
||||||
let p = execa.command(`php ${dep} ${core.getInput('dep')}`)
|
let p = execa.command(`php ${dep} --ansi -v ${core.getInput('dep')}`)
|
||||||
p.stdout.pipe(process.stdout)
|
p.stdout.pipe(process.stdout)
|
||||||
p.stderr.pipe(process.stderr)
|
p.stderr.pipe(process.stderr)
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user