-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
55 lines (49 loc) · 1.53 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: 'Sora ssh action'
description: "Server management action. A wrapper around appleboy's ssh-action. Allows to pull/deploy repo or just run some code."
inputs:
# meta
pull:
description: 'whether to pull'
required: true
default: true
deploy:
description: 'name of the service that needs to be deployed'
script:
description: 'additional script if needed'
# ssh
host:
description: 'host'
required: true
port:
description: 'port'
required: true
default: 22
username:
description: 'username'
password:
description: 'password'
runs:
using: 'composite'
steps:
- name: Deploy to ssh server
uses: appleboy/[email protected]
with:
host: ${{ inputs.host }}
port: ${{ inputs.port }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
script : |
. $HOME/.profile
cd "$DEPLOYMENT_DIR"
CURRENT_BRANCH=$(git branch --show-current)
[ '${{ inputs.pull }}' = 'true' -a '${{ github.ref_name }}' = "$CURRENT_BRANCH" ] && \
make set-commit deployment
[ -n '${{ inputs.deploy }}' ] && \
make set-commit ${{ inputs.deploy }}
make deploy ${{ inputs.deploy }}
# don't use && since we don't need to escape quotes and eval string
if [ -n '${{ inputs.script }}' ]; then
# make body not empty even if script is not provided (bash -c fails to parse empty if body)
true;
${{ inputs.script }}
fi