-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
89 lines (84 loc) · 2.94 KB
/
action.yml
File metadata and controls
89 lines (84 loc) · 2.94 KB
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
85
86
87
88
89
name: "Plesk Deployer"
description: "Deploy applications and resources to a Plesk server via SCP"
branding:
icon: arrow-up-circle
color: gray-dark
inputs:
ssh-private-key:
description: "SSH private key for authentication"
required: true
ftp-username:
description: "FTP username for Plesk server"
required: true
ftp-server:
description: "FTP server address"
required: true
files-to-copy:
description: "Files or directories to copy to the server"
required: true
remote-dir:
description: "Remote directory to copy files to"
required: false
default: "/"
node-version:
description: "Node version running your project in plesk"
required: false
default: "20"
package-manager:
description: "Package manager to use (npm or yarn)"
default: "npm"
required: false
npm-install:
description: "Whether to install dependencies"
required: false
default: "true"
restart:
description: "Whether to restart the application"
required: false
default: "true"
clean-remote-dir:
description: "Whether to clean the remote directory before deployment"
required: false
default: "false"
outputs:
deployment-status:
description: "Status of the deployment"
value: ${{ steps.deploy-to-plesk.outcome }}
runs:
using: "composite"
steps:
- name: Setup SSH
uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: ${{ inputs.ssh-private-key }}
- name: Add server to known hosts
run: |
ssh-keyscan -H ${{ inputs.ftp-server }} >> ~/.ssh/known_hosts
shell: bash
- name: Clean remote directory
if: ${{ inputs.clean-remote-dir == 'true' }}
run: |
ssh ${{ inputs.ftp-username }}@${{ inputs.ftp-server }} 'rm -rf ${{ inputs.remote-dir }}/*'
shell: bash
- name: Deploy to Plesk
id: deploy-to-plesk
run: |
scp -o StrictHostKeyChecking=yes -r ${{ inputs.files-to-copy }} ${{ inputs.ftp-username }}@${{ inputs.ftp-server }}:${{ inputs.remote-dir }}
shell: bash
- name: Install dependencies
if: ${{ inputs.npm-install == 'true' }}
run: |
if [ "${{ inputs.package-manager }}" == "npm" ]; then
ssh ${{ inputs.ftp-username }}@${{ inputs.ftp-server }} 'export PATH=$PATH:/opt/plesk/node/${{ inputs.node-version }}/bin && cd ${{ inputs.remote-dir }} && npm ci'
elif [ "${{ inputs.package-manager }}" == "yarn" ]; then
ssh ${{ inputs.ftp-username }}@${{ inputs.ftp-server }} 'export PATH=$PATH:/opt/plesk/node/${{ inputs.node-version }}/bin && cd ${{ inputs.remote-dir }} && yarn install --frozen-lockfile'
else
echo "Invalid package manager specified. Use 'npm' or 'yarn'."
exit 1
fi
shell: bash
- name: Restart application
if: ${{ inputs.restart == 'true' }}
run: |
ssh ${{ inputs.ftp-username }}@${{ inputs.ftp-server }} 'cd ${{ inputs.remote-dir }} && touch tmp/restart.txt'
shell: bash