-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
69 lines (58 loc) · 2.14 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: 'Deploy via SSH'
description: 'Deploys files to a remote server via SSH'
inputs:
ssh-private-key:
description: 'A private SSH key. The public fingerprint must be added to the server'
required: true
ssh-host:
description: 'The address (IP or DNS) of the remote server'
required: true
ssh-user:
description: 'SSH username'
required: true
deployment-path:
description: 'Relative path from mount location where to upload files to'
required: true
ignored-files:
description: 'Files or paths to ignore from upload'
required: false
default: ./.git ./.github ./node_modules ./tests ./.env.local
pre-deploy-commands:
description: 'Commands to run pre deployment'
required: false
default: ''
post-deploy-commands:
description: 'Commands to run after deployment'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ inputs.ssh-private-key }}
known_hosts: '--placeholder-host'
- name: Adding known hosts
run: ssh-keyscan -H ${{ inputs.ssh-host }} >> ~/.ssh/known_hosts
shell: bash
- name: Remove redundant files
run: rm -fr ${{ inputs.ignored-files }}
shell: bash
- name: Create archive
run: tar -zcvf ../build.tar.gz .
shell: bash
- name: Deploy with scp
run: scp ../build.tar.gz ${{ inputs.ssh-user }}@${{ inputs.ssh-host }}:${{ inputs.deployment-path }}
shell: bash
- name: Pre-Deploy Commands
if: ${{ inputs.pre-deploy-commands != '' }}
run: ssh ${{ inputs.ssh-user }}@${{ inputs.ssh-host }} 'cd ${{ inputs.deployment-path }}; ${{ inputs.pre-deploy-commands }}'
shell: bash
- name: Extract archive on remote host
run: ssh ${{ inputs.ssh-user }}@${{ inputs.ssh-host }} 'cd ${{ inputs.deployment-path }}; tar -xf build.tar.gz; rm build.tar.gz'
shell: bash
- name: Post-Deploy Commands
if: ${{ inputs.post-deploy-commands != '' }}
run: ssh ${{ inputs.ssh-user }}@${{ inputs.ssh-host }} 'cd ${{ inputs.deployment-path }}; ${{ inputs.post-deploy-commands }}'
shell: bash