forked from radenpioneer/astro-ftp-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
116 lines (110 loc) · 3.44 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: "Astro FTP"
description: "A composite action that prepares your Astro site to be deployed to any FTP server."
branding:
icon: "box"
color: "orange"
inputs:
server:
description: "FTP server hostname"
required: true
username:
description: "FTP username"
required: true
password:
description: "FTP password"
required: true
directory:
description: "Path to upload to (on the server). Must end with trailing slash /"
required: false
default: "public_html/"
protocol:
description: "Protocol to use, supports `ftp`, `ftps` and `ftps-legacy`. Defaults to `ftp`"
required: false
default: "ftp"
port:
description: "Remote server port"
required: false
default: "21"
path:
description: "Path of the directory containing your site"
required: false
default: "."
node-version:
description: "The node version to use"
required: false
default: "18"
package-manager:
description: "If not automatically detectable, you may specify your preferred package manager"
required: false
default: ""
resolve-dep-from-path:
description: "If the dependency file is located inside the folder specified by path"
type: boolean
required: false
default: true
dry-run:
description:
required: false
default: false
runs:
using: composite
steps:
- name: Check lockfiles
shell: "bash"
env:
INPUT_PM: ${{ inputs.package-manager }}
run: |
len=`echo $INPUT_PM | wc -c`
if [ $len -gt 1 ]; then
echo "PACKAGE_MANAGER=$INPUT_PM" >> $GITHUB_ENV
elif [ $(find "." -name "pnpm-lock.yaml") ]; then
echo "PACKAGE_MANAGER=pnpm" >> $GITHUB_ENV
echo "LOCKFILE=pnpm-lock.yaml" >> $GITHUB_ENV
elif [ $(find "." -name "yarn.lock") ]; then
echo "PACKAGE_MANAGER=yarn" >> $GITHUB_ENV
echo "LOCKFILE=yarn.lock" >> $GITHUB_ENV
elif [ $(find "." -name "package-lock.json") ]; then
echo "PACKAGE_MANAGER=npm" >> $GITHUB_ENV
echo "LOCKFILE=package-lock.json" >> $GITHUB_ENV
else
echo "No lockfile found.
Please specify your preferred \"package-manager\" in the action configuration."
exit 1
fi
- name: Setup PNPM
if: ${{ env.PACKAGE_MANAGER == 'pnpm' }}
uses: pnpm/[email protected]
- name: Setup Node
uses: actions/setup-node@v4
if: inputs.resolve-dep-from-path == true
with:
node-version: ${{ inputs.node-version }}
cache: ${{ env.PACKAGE_MANAGER }}
cache-dependency-path: "${{ inputs.path }}/${{ env.LOCKFILE }}"
- name: Setup Node
uses: actions/setup-node@v4
if: inputs.resolve-dep-from-path == false
with:
node-version: ${{ inputs.node-version }}
cache: ${{ env.PACKAGE_MANAGER }}
- name: Install
shell: "bash"
run: |
cd ${{ inputs.path }}
$PACKAGE_MANAGER install
- name: Build
shell: "bash"
run: |
cd ${{ inputs.path }}
$PACKAGE_MANAGER run build
- name: Upload to FTP Server
uses: SamKirkland/[email protected]
with:
server: ${{ inputs.server }}
port: ${{ inputs.port }}
protocol: ${{ inputs.protocol }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
server-dir: ${{ inputs.directory }}
dry-run: ${{ inputs.dry-run }}
local-dir: ./dist/