-
Notifications
You must be signed in to change notification settings - Fork 115
74 lines (64 loc) · 2.26 KB
/
Copy pathdeploy.yml
File metadata and controls
74 lines (64 loc) · 2.26 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
name: ssh deploy
on:
push:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20.11
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies and build
run: |
npm install -g pnpm@8.15.5
pnpm i
pnpm run build:4096
- name: Compress build output
run: tar -czf dist.tar.gz -C dist .
- name: Clean target directory
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.C_HOST }}
username: ${{ secrets.C_USER }}
password: ${{ secrets.C_PASS }}
script: |
echo "Cleaning target directory..."
cd /home/thingspanel/nginx/www
# Remove old dist.tar.gz if exists (file or directory)
rm -rf dist.tar.gz
# Create dist directory if it doesn't exist
mkdir -p dist
# Clean up old files in dist directory
rm -rf dist/*
- name: Install SSH Pass
run: sudo apt-get update && sudo apt-get install -y sshpass
- name: Copy files to server
run: |
sshpass -p "${{ secrets.C_PASS }}" scp -o StrictHostKeyChecking=no dist.tar.gz ${{ secrets.C_USER }}@${{ secrets.C_HOST }}:/home/thingspanel/nginx/www/
- name: Deploy on server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.C_HOST }}
username: ${{ secrets.C_USER }}
password: ${{ secrets.C_PASS }}
script: |
echo "Starting deployment..."
cd /home/thingspanel/nginx/www
# Extract new files to dist directory
tar -xzf dist.tar.gz -C dist
# Remove the tar file
rm -f dist.tar.gz
# Test nginx and reload
nginx -t && nginx -s reload
echo "Deployment completed successfully."