Skip to content

feat: 添加同步到 GitHub 的中文日志说明 #125

feat: 添加同步到 GitHub 的中文日志说明

feat: 添加同步到 GitHub 的中文日志说明 #125

Workflow file for this run

name: Sync to GitHub and CNB
on:
push:
branches: [ "master" ]
workflow_dispatch:
permissions:
contents: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Add CNB remote
run: |
git remote add cnb https://cnb.cool/ImAcaiy/Automation_Platform.git || git remote set-url cnb https://cnb.cool/ImAcaiy/Automation_Platform.git
- name: Sync to CNB
continue-on-error: true
id: cnb-sync
env:
CNB_TOKEN: ${{ secrets.CNB_TOKEN }}
run: |
echo "Syncing to CNB..."
# Set Git timeout
git config --global http.lowSpeedLimit 1000
git config --global http.lowSpeedTime 60
git config --global http.postBuffer 524288000
# Retry logic
MAX_RETRIES=3
RETRY_COUNT=0
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
echo "Attempt $((RETRY_COUNT + 1)) of $MAX_RETRIES..."
if git push https://x-access-token:${CNB_TOKEN}@cnb.cool/ImAcaiy/Automation_Platform.git HEAD:master --force; then
echo "CNB sync completed successfully!"
exit 0
fi
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
echo "Sync failed, retrying in 10 seconds..."
sleep 10
fi
done
echo "CNB sync failed after $MAX_RETRIES attempts"
exit 1
- name: Report CNB sync status
if: always()
run: |
if [ "${{ steps.cnb-sync.outcome }}" == "success" ]; then
echo "✅ CNB sync succeeded"
else
echo "⚠️ CNB sync failed or was skipped"
echo "This may be due to network connectivity issues between GitHub Actions and cnb.cool"
echo "GitHub sync will continue regardless"
fi
- name: Add GitHub remote
run: |
git remote add github https://github.com/acai1998/Automation_Platform.git || git remote set-url github https://github.com/acai1998/Automation_Platform.git
- name: Sync to GitHub
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
echo "Syncing to GitHub..."
git push https://x-access-token:${GITHUB_TOKEN}@github.com/acai1998/Automation_Platform.git HEAD:master
echo "GitHub sync completed!"