Update deploy.yml

This commit is contained in:
Vaica committed 2026-06-27 19:36:51 +08:00
1 parent 2a403918c9
commit a70f62bc76
1 file changed
+35 -4
+35 -4
View File
@@ -63,6 +63,27 @@ jobs:
echo "⚠️ 提交信息格式建议: feat/fix/chore/docs/style/refactor/test: description" echo "⚠️ 提交信息格式建议: feat/fix/chore/docs/style/refactor/test: description"
fi fi
- name: Check for new commits (only for cron)
if: github.event_name == 'schedule'
id: cron-check
run: |
LAST_COMMIT_TIME=$(git log -1 --format=%ct)
CURRENT_TIME=$(date +%s)
DIFF_HOURS=$(( (CURRENT_TIME - LAST_COMMIT_TIME) / 3600 ))
echo "⏰ 最后一次提交时间: $(date -d @$LAST_COMMIT_TIME)"
echo "⏰ 当前时间: $(date)"
echo "⏰ 距离上次提交: $DIFF_HOURS 小时"
if [ "$DIFF_HOURS" -lt 1 ]; then
echo "✅ 最近有提交,继续构建"
echo "can_deploy=true" >> $GITHUB_OUTPUT
else
echo "⏭️ 超过 1 小时没有新提交,跳过定时构建"
echo "can_deploy=false" >> $GITHUB_OUTPUT
exit 0
fi
- name: Summary - name: Summary
run: | run: |
echo "## 🔍 前置检查完成" >> $GITHUB_STEP_SUMMARY echo "## 🔍 前置检查完成" >> $GITHUB_STEP_SUMMARY
@@ -176,7 +197,6 @@ jobs:
name: hugo-public name: hugo-public
path: public/ path: public/
retention-days: 1 retention-days: 1
compression-level: 0
- name: Push Image Optimizations - name: Push Image Optimizations
continue-on-error: true continue-on-error: true
@@ -265,7 +285,7 @@ jobs:
if: steps.check.outputs.deployed == 'true' if: steps.check.outputs.deployed == 'true'
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 1
- name: Download build artifact - name: Download build artifact
if: steps.check.outputs.deployed == 'true' if: steps.check.outputs.deployed == 'true'
@@ -485,7 +505,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5 timeout-minutes: 5
permissions: permissions:
contents: read contents: write
needs: [pre-check, build, deploy-edgeone, deploy-upyun] needs: [pre-check, build, deploy-edgeone, deploy-upyun]
if: always() && needs.build.result == 'success' && needs.deploy-edgeone.result == 'success' && needs.deploy-upyun.result == 'success' if: always() && needs.build.result == 'success' && needs.deploy-edgeone.result == 'success' && needs.deploy-upyun.result == 'success'
@@ -497,7 +517,7 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 1
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
@@ -807,6 +827,17 @@ jobs:
echo "| UpYun | ${{ needs.deploy-upyun.outputs.deployed == 'true' && '✅ 已部署' || '⏭️ 跳过(无变化)' }} |" >> $GITHUB_STEP_SUMMARY echo "| UpYun | ${{ needs.deploy-upyun.outputs.deployed == 'true' && '✅ 已部署' || '⏭️ 跳过(无变化)' }} |" >> $GITHUB_STEP_SUMMARY
echo "| CDN 刷新 | ${{ steps.deploy-status.outputs.any_deployed == 'true' && '✅ 已刷新' || '⏭️ 跳过' }} |" >> $GITHUB_STEP_SUMMARY echo "| CDN 刷新 | ${{ steps.deploy-status.outputs.any_deployed == 'true' && '✅ 已刷新' || '⏭️ 跳过' }} |" >> $GITHUB_STEP_SUMMARY
- name: Clean up build artifact
uses: actions/delete-artifact@v4
with:
name: hugo-public
- name: Clean up old caches
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache || true
gh actions-cache delete --all --confirm || true
# ============================================================ # ============================================================
# Job 6: Failure Notification (失败通知) # Job 6: Failure Notification (失败通知)
# ============================================================ # ============================================================