-
Notifications
You must be signed in to change notification settings - Fork 72
81 lines (67 loc) · 2.54 KB
/
Copy pathdeploy.yml
File metadata and controls
81 lines (67 loc) · 2.54 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
name: deploy
on:
workflow_dispatch:
inputs:
github_access_token:
description: 'github access token'
required: true
type: string
env:
ADMIN_GITHUB_TOKEN: ${{ inputs.github_access_token }}
jobs:
download:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Set timezone to Asia/Shanghai
run: |
sudo timedatectl set-timezone Asia/Shanghai
date
- name: Checkout spark-yun-vip
uses: actions/checkout@v4
with:
token: ${{ env.ADMIN_GITHUB_TOKEN }}
repository: "isxcode/spark-yun-vip"
ref: 'main'
- name: Deploy zhiqingyun
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
timeout: 1800s
command_timeout: 1800s
script: |
set -e
rm -rf /tmp/zhiqingyun.tar.gz
# jar 进程可能不存在,不应视为失败
jps | awk '/zhiqingyun.jar/ {print $1}' | xargs -r kill -9 || true
cp /data/file/zhiqingyun.tar.gz /tmp/zhiqingyun.tar.gz
tar -vzxf /tmp/zhiqingyun.tar.gz -C /opt/
rm -rf /tmp/zhiqingyun.tar.gz
if [ -d "/opt/zhiqingyun/resources_back" ]; then
rm -rf /opt/zhiqingyun/resources
mv /opt/zhiqingyun/resources_back /opt/zhiqingyun/resources
fi
rm -rf /opt/zhiqingyun/conf/application-local.yml
cp /root/application-local.yml /opt/zhiqingyun/conf/application-local.yml
cp -r /opt/zhiqingyun/resources /opt/zhiqingyun/resources_bak/resources_$(date +'%Y-%m-%d-%H-%M-%S')_bak
rm -rf /tmp/libprql_*
rm -rf /tmp/tomcat.8080.*
rm -rf /tmp/tomcat-docbase.8080.*
# 某些启动脚本会在“已触发启动”后返回非 0,交由健康检查判定最终成功与否
bash /opt/zhiqingyun/bin/start.sh --print-log=false || true
sleep 120
end_time=$((SECONDS + 600))
until curl -fsS https://zhiqingyun-demo.isxcode.com/tools/open/health | grep -q "UP"; do
if [ "$SECONDS" -ge "$end_time" ]; then
echo "Health check timeout after 600s"
exit 1
fi
echo "Waiting for service to be available..."
sleep 1
done
echo "Deploy completed and health check is UP"