-
Notifications
You must be signed in to change notification settings - Fork 72
69 lines (55 loc) · 1.99 KB
/
Copy pathrollback.yml
File metadata and controls
69 lines (55 loc) · 1.99 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
name: rollback
#on:
# schedule:
# - cron: '59 15 * * *'
on:
workflow_dispatch:
jobs:
download:
if: false
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: Deploy zhiqingyun rollback
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
# jar 进程可能不存在,不应视为失败
jps | awk '/zhiqingyun.jar/ {print $1}' | xargs -r kill -9 || true
if [ -d "/opt/zhiqingyun/resources_back" ]; then
rm -rf /opt/zhiqingyun/resources/*
cp -r /opt/zhiqingyun/resources_back/* /opt/zhiqingyun/resources/
fi
if [ ! -d "/opt/zhiqingyun/resources_back" ]; then
mkdir -p /opt/zhiqingyun/resources_back
cp -r /opt/zhiqingyun/resources/* /opt/zhiqingyun/resources_back/
fi
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 "Rollback completed and health check is UP"