构建优化
This commit is contained in:
@@ -13,13 +13,64 @@ jobs:
|
|||||||
name: Build Docker Image
|
name: Build Docker Image
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# ✅ 使用 Gitea 兼容的代码检出方式
|
# 网络连接测试
|
||||||
|
- name: Test network connectivity
|
||||||
|
run: |
|
||||||
|
echo "Testing network connectivity to Gitea server..."
|
||||||
|
MAX_RETRIES=5
|
||||||
|
RETRY_DELAY=10
|
||||||
|
|
||||||
|
for i in $(seq 1 $MAX_RETRIES); do
|
||||||
|
echo "Network test attempt $i/$MAX_RETRIES"
|
||||||
|
if curl -s --connect-timeout 10 -f http://192.168.31.14:14200 > /dev/null; then
|
||||||
|
echo "✅ Gitea server is reachable"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "❌ Network test failed, waiting $RETRY_DELAY seconds..."
|
||||||
|
sleep $RETRY_DELAY
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "❌ All network tests failed"
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: https://gitea.com/actions/checkout@v3
|
uses: https://gitea.com/actions/checkout@v3
|
||||||
with:
|
# 添加重试策略
|
||||||
gitea-server: http://192.168.31.14:14200
|
continue-on-error: true
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
ref: ${{ gitea.ref }} # 必须传递 Gitea 的 ref 参数
|
# 手动重试逻辑
|
||||||
|
- name: Retry checkout if failed
|
||||||
|
if: steps.checkout.outcome == 'failure'
|
||||||
|
run: |
|
||||||
|
echo "First checkout attempt failed, retrying..."
|
||||||
|
MAX_RETRIES=3
|
||||||
|
RETRY_DELAY=15
|
||||||
|
|
||||||
|
for i in $(seq 1 $MAX_RETRIES); do
|
||||||
|
echo "Retry attempt $i/$MAX_RETRIES"
|
||||||
|
|
||||||
|
# 清理可能的部分检出
|
||||||
|
rm -rf .git || true
|
||||||
|
git clean -fdx || true
|
||||||
|
|
||||||
|
# 使用git命令直接检出
|
||||||
|
git init
|
||||||
|
git remote add origin http://192.168.31.14:14200/${{ gitea.repository }}
|
||||||
|
git config http.extraHeader "Authorization: Bearer ${{ secrets.GITEA_TOKEN }}"
|
||||||
|
|
||||||
|
if git fetch --depth=1 origin "${{ gitea.ref }}"; then
|
||||||
|
git checkout FETCH_HEAD
|
||||||
|
echo "Checkout successful on retry $i"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Retry $i failed, waiting $RETRY_DELAY seconds..."
|
||||||
|
sleep $RETRY_DELAY
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All checkout attempts failed"
|
||||||
|
exit 1
|
||||||
|
|
||||||
- name: Cleanup old containers
|
- name: Cleanup old containers
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user