edit core feature #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Sync | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
auto_sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy Stage | |
run: | | |
# 启用错误处理 | |
set -e | |
# 执行 API 请求并捕获响应 | |
RESPONSE=$(curl -X POST ${{ secrets.ZBOOK_URI }} \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"repo_name": "${{ secrets.ZBOOK_REPO_NAME }}", | |
"username": "${{ secrets.ZBOOK_USERNAME }}", | |
"sync_token": "${{ secrets.ZBOOK_SYNC_TOKEN }}" | |
}' --max-time 600) | |
# 输出响应内容 | |
echo "Response: $RESPONSE" | |
# 检查响应内容是否为空 | |
if [ -z "$RESPONSE" ]; then | |
echo "Error: Empty response from API" | |
exit 1 | |
fi | |
# 检查响应中是否包含预期的内容(例如状态码或关键字段) | |
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." |