-
Notifications
You must be signed in to change notification settings - Fork 1
36 lines (28 loc) · 1 KB
/
auto_sync.yaml
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
name: Auto Sync
on:
push:
branches:
- main
jobs:
auto_sync:
runs-on: ubuntu-latest
steps:
- name: Deploy Stage
run: |
# 启用错误处理
set -e
# 构建带参数的 GET 请求 URL
URL="${{ secrets.ZBOOK_URI }}?username=${{ secrets.ZBOOK_USERNAME }}&sync_token=${{ secrets.ZBOOK_SYNC_TOKEN }}&repo_name=${{ secrets.ZBOOK_REPO_NAME }}"
# 执行 GET 请求并捕获响应
RESPONSE=$(curl -X GET "$URL" \
-H 'Content-Type: application/json' \
--max-time 600)
# 输出响应内容
echo "Response: $RESPONSE"
# 检查响应中是否包含预期的内容(例如状态码或关键字段)
STATUS_CODE=$(echo "$RESPONSE" | grep -oP '(?<="status":)\d+' || echo "200")
if [ "$STATUS_CODE" -ne 200 ]; then
echo "Error: API request failed with status code $STATUS_CODE"
exit 1
fi
echo "API request successful."