Feature/multi lang (#3) #76
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 | |
# 构建带参数的 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." |