Skip to content

Commit 2c2db8c

Browse files
committed
Update action
1 parent c17d254 commit 2c2db8c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1428
-4761
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Anton Medvedev
3+
Copyright (c) 2021 Anton Medvedev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,24 @@
22

33
```yaml
44
- name: Deploy
5-
uses: deployphp/action@master
5+
uses: deployphp/action@1
66
with:
77
private-key: ${{ secrets.PRIVATE_KEY }}
8-
known-hosts: ${{ secrets.KNOWN_HOSTS }}
9-
ssh-config: ${{ secrets.SSH_CONFIG }}
10-
dep: deploy prod -v
8+
dep: deploy all
119
```
1210
1311
## Inputs
1412
15-
- `private-key` - Required. A private key to accessing servers.
16-
- `known-hosts` - Optional. Host fingerprints. If omitted `StrictHostKeyChecking=no` will be used unless `ssh-config` is provided.
17-
- `ssh-config` - Optional. SSH configuration.
18-
- `dep` - Required. Arguments to pass to Deployer command.
13+
See [action.yaml](action.yaml).
1914
2015
## Deployer version
2116
22-
First, the action will check for Deployer bin at those paths:
17+
First, the action will check for Deployer binary at those paths:
2318
- `vendor/bin/dep`
24-
- `bin/dep`
2519
- `deployer.phar`
2620

27-
If bin not found, phar version will be downloaded.
21+
If the binary not found, phar version will be downloaded from
22+
[deployer.org](https://deployer.org/download).
2823

2924
## Example
3025

action.yaml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
name: 'deployphp/action'
2+
23
description: 'Deploy with Deployer'
4+
35
inputs:
6+
47
private-key:
5-
description: 'Private key'
68
required: true
9+
description: >
10+
Private key for connecting to remote hosts. To generate private key:
11+
`ssh-keygen -o -t rsa -C '[email protected]'`.
12+
13+
dep:
14+
required: true
15+
description: >
16+
The deployer task to run. For example:
17+
`deploy all`.
18+
719
known-hosts:
8-
description: 'Known hosts'
920
required: false
1021
default: ''
22+
description: >
23+
Content of `~/.ssh/known_hosts` file. The public SSH keys for a
24+
host may be obtained using the utility `ssh-keyscan`. For example,
25+
`ssh-keyscan deployer.org`.
26+
27+
If known-hosts omitted, `StrictHostKeyChecking no` will be added to
28+
`ssh_config`.
29+
1130
ssh-config:
12-
description: 'SSH configuration'
13-
required: false
14-
default: ''
15-
dep:
16-
description: 'Deployer command'
1731
required: false
1832
default: ''
33+
description: >
34+
The SSH configuration.
35+
1936
runs:
2037
using: 'node12'
2138
main: 'index.js'
39+
2240
branding:
2341
color: blue
2442
icon: send

index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
const core = require('@actions/core')
22
const fs = require('fs')
33
const execa = require('execa')
4-
const split = require('argv-split')
54

6-
void function main() {
5+
void async function main() {
76
try {
8-
ssh()
9-
dep()
7+
await ssh()
8+
await dep()
109
} catch (err) {
1110
core.setFailed(err.message)
1211
}
1312
}()
1413

15-
function ssh() {
14+
async function ssh() {
1615
let ssh = `${process.env['HOME']}/.ssh`
1716

1817
if (!fs.existsSync(ssh)) {
@@ -37,14 +36,14 @@ function ssh() {
3736

3837
const sshConfig = core.getInput('ssh-config')
3938
if (sshConfig !== '') {
40-
fs.writeFile(`${ssh}/config`, sshConfig)
39+
fs.writeFileSync(`${ssh}/config`, sshConfig)
4140
fs.chmodSync(`${ssh}/config`, '600')
4241
}
4342
}
4443

45-
function dep() {
44+
async function dep() {
4645
let dep
47-
for (let c of ['vendor/bin/dep', 'bin/dep', 'deployer.phar']) {
46+
for (let c of ['vendor/bin/dep', 'deployer.phar']) {
4847
if (fs.existsSync(c)) {
4948
dep = c
5049
break
@@ -54,14 +53,15 @@ function dep() {
5453
if (!dep) {
5554
execa.commandSync('curl -LO https://deployer.org/deployer.phar')
5655
execa.commandSync('sudo chmod +x deployer.phar')
57-
dep = './deployer.phar'
56+
dep = 'deployer.phar'
5857
}
5958

60-
const subprocess = execa(dep, split(core.getInput('dep')))
61-
62-
subprocess.stdout.pipe(process.stdout);
63-
64-
subprocess.catch(err => {
59+
let p = execa.command(`php ${dep} ${core.getInput('dep')}`)
60+
p.stdout.pipe(process.stdout)
61+
p.stderr.pipe(process.stderr)
62+
try {
63+
await p
64+
} catch (err) {
6565
core.setFailed(err.shortMessage)
66-
})
66+
}
6767
}

node_modules/@actions/core/README.md

Lines changed: 115 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)