-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
84 lines (76 loc) · 2.25 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: 'PM2 Deployment'
description: 'Deploy your nodejs or typescript app with PM2'
branding:
icon: "zap"
color: "yellow"
inputs:
build:
required: false
default: 'false'
host:
description: "Remote host"
required: true
username:
description: "Username to login"
required: true
port:
description: "SSH port"
required: false
default: "22"
password:
description: "SSH password"
required: true
remote-path:
description: "Remote path where the files are going to be copied"
required: true
pm2-id:
description: "PM2 ID or Name of the process"
required: true
runs:
using: "composite"
steps:
- name: Get repository content
uses: actions/checkout@v3
- name: Copy repository content
uses: appleboy/scp-action@v0.1.2
env:
HOST: ${{ inputs.host }}
USERNAME: ${{ inputs.username }}
PORT: ${{ inputs.port }}
PASSWORD: ${{ inputs.password }}
with:
source: "."
target: ${{ inputs.remote-path }}
- name: Install project
uses: appleboy/ssh-action@v0.1.4
with:
HOST: ${{ inputs.host }}
USERNAME: ${{ inputs.username }}
PORT: ${{ inputs.port }}
PASSWORD: ${{ inputs.password }}
script: cd ${{ inputs.remote-path }} && npm ci
- name: Build your project
if: ${{ inputs.build == true }}
uses: appleboy/ssh-action@v0.1.4
with:
HOST: ${{ inputs.host }}
USERNAME: ${{ inputs.username }}
PORT: ${{ inputs.port }}
PASSWORD: ${{ inputs.password }}
script: cd ${{ inputs.remote-path }} && npm run build
- name: Reload remote application
uses: appleboy/ssh-action@v0.1.4
with:
HOST: ${{ inputs.host }}
USERNAME: ${{ inputs.username }}
PORT: ${{ inputs.port }}
PASSWORD: ${{ inputs.password }}
script: cd ${{ inputs.remote-path }} && pm2 reload ecosystem.config.js
- name: Reset number of restarts
uses: appleboy/ssh-action@v0.1.4
with:
HOST: ${{ inputs.host }}
USERNAME: ${{ inputs.username }}
PORT: ${{ inputs.port }}
PASSWORD: ${{ inputs.password }}
script: pm2 reset ${{ inputs.pm2-id }}