0019
This commit is contained in:
1 parent
9e21e30ff5
commit
4c1f23d97e
2 files changed
+138
-7
No files matched your search
@@ -19,7 +19,7 @@ on:
|
|||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: false
|
||||||
|
|
||||||
env:
|
env:
|
||||||
TZ: Asia/Shanghai
|
TZ: Asia/Shanghai
|
||||||
@@ -35,6 +35,10 @@ jobs:
|
|||||||
can_deploy: ${{ steps.repo-check.outputs.can_deploy }}
|
can_deploy: ${{ steps.repo-check.outputs.can_deploy }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Start timing
|
||||||
|
id: start-pre-check
|
||||||
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -76,6 +80,15 @@ jobs:
|
|||||||
echo "- **触发方式**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **触发方式**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Commit SHA**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Commit SHA**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
- name: End timing
|
||||||
|
id: end-pre-check
|
||||||
|
run: |
|
||||||
|
end_time=$(date +%s)
|
||||||
|
start_time=${{ steps.start-pre-check.outputs.start_time }}
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
echo "duration=${duration}" >> $GITHUB_OUTPUT
|
||||||
|
echo "## ⏱️ Pre-check 耗时: ${duration}秒" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Job 1: Font Subset (字体子集化 - 可选并行任务)
|
# Job 1: Font Subset (字体子集化 - 可选并行任务)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -93,8 +106,12 @@ jobs:
|
|||||||
char_count: ${{ steps.stats.outputs.char_count }}
|
char_count: ${{ steps.stats.outputs.char_count }}
|
||||||
original_size: ${{ steps.stats.outputs.original_size }}
|
original_size: ${{ steps.stats.outputs.original_size }}
|
||||||
subset_size: ${{ steps.stats.outputs.subset_size }}
|
subset_size: ${{ steps.stats.outputs.subset_size }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Start timing
|
||||||
|
id: start-subset
|
||||||
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -217,6 +234,15 @@ jobs:
|
|||||||
}'
|
}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: End timing
|
||||||
|
id: end-subset
|
||||||
|
run: |
|
||||||
|
end_time=$(date +%s)
|
||||||
|
start_time=${{ steps.start-subset.outputs.start_time }}
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
echo "duration=${duration}" >> $GITHUB_OUTPUT
|
||||||
|
echo "## ⏱️ Subset-fonts 耗时: ${duration}秒" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Job 2: Build (构建)
|
# Job 2: Build (构建)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -229,8 +255,12 @@ jobs:
|
|||||||
build_hash: ${{ steps.hash.outputs.build_hash }}
|
build_hash: ${{ steps.hash.outputs.build_hash }}
|
||||||
needs: pre-check
|
needs: pre-check
|
||||||
if: needs.pre-check.outputs.can_deploy == 'true'
|
if: needs.pre-check.outputs.can_deploy == 'true'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Start timing
|
||||||
|
id: start-build
|
||||||
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -310,6 +340,15 @@ jobs:
|
|||||||
echo "No auto-commits to push"
|
echo "No auto-commits to push"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: End timing
|
||||||
|
id: end-build
|
||||||
|
run: |
|
||||||
|
end_time=$(date +%s)
|
||||||
|
start_time=${{ steps.start-build.outputs.start_time }}
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
echo "duration=${duration}" >> $GITHUB_OUTPUT
|
||||||
|
echo "## ⏱️ Build 耗时: ${duration}秒" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Job 3: Deploy to EdgeOne Pages (并行)
|
# Job 3: Deploy to EdgeOne Pages (并行)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -319,8 +358,12 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
needs: build
|
needs: build
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Start timing
|
||||||
|
id: start-edgeone
|
||||||
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code (for scripts)
|
- name: Checkout code (for scripts)
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -339,17 +382,30 @@ jobs:
|
|||||||
chmod +x scripts/deploy_edgeone.sh
|
chmod +x scripts/deploy_edgeone.sh
|
||||||
./scripts/deploy_edgeone.sh hugo-blog ./public overseas
|
./scripts/deploy_edgeone.sh hugo-blog ./public overseas
|
||||||
|
|
||||||
|
- name: End timing
|
||||||
|
id: end-edgeone
|
||||||
|
run: |
|
||||||
|
end_time=$(date +%s)
|
||||||
|
start_time=${{ steps.start-edgeone.outputs.start_time }}
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
echo "duration=${duration}" >> $GITHUB_OUTPUT
|
||||||
|
echo "## ⏱️ Deploy EdgeOne 耗时: ${duration}秒" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Job 4: Deploy to UpYun (并行)
|
# Job 4: Deploy to UpYun (并行)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
deploy-upyun:
|
deploy-upyun:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 20
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
needs: build
|
needs: build
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Start timing
|
||||||
|
id: start-upyun
|
||||||
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Download build artifact
|
- name: Download build artifact
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -365,6 +421,15 @@ jobs:
|
|||||||
dir: 'public'
|
dir: 'public'
|
||||||
publish_dir: '/'
|
publish_dir: '/'
|
||||||
|
|
||||||
|
- name: End timing
|
||||||
|
id: end-upyun
|
||||||
|
run: |
|
||||||
|
end_time=$(date +%s)
|
||||||
|
start_time=${{ steps.start-upyun.outputs.start_time }}
|
||||||
|
duration=$((end_time - start_time))
|
||||||
|
echo "duration=${duration}" >> $GITHUB_OUTPUT
|
||||||
|
echo "## ⏱️ Deploy UpYun 耗时: ${duration}秒" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Job 5: CDN Refresh & Notifications (在所有部署完成后)
|
# Job 5: CDN Refresh & Notifications (在所有部署完成后)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -374,8 +439,12 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
needs: [deploy-edgeone, deploy-upyun]
|
needs: [deploy-edgeone, deploy-upyun]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Start timing
|
||||||
|
id: start-finalize
|
||||||
|
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -465,6 +534,26 @@ jobs:
|
|||||||
body: |
|
body: |
|
||||||
${{ env.DEPLOY_REPORT }}
|
${{ env.DEPLOY_REPORT }}
|
||||||
|
|
||||||
|
- name: Generate timing summary
|
||||||
|
id: timing-summary
|
||||||
|
run: |
|
||||||
|
end_time=$(date +%s)
|
||||||
|
start_time=${{ steps.start-finalize.outputs.start_time }}
|
||||||
|
finalize_duration=$((end_time - start_time))
|
||||||
|
|
||||||
|
echo "## ⏱️ 部署耗时统计" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| 阶段 | 耗时 |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "|------|------|" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Pre-check | ${{ needs.pre-check.result == 'success' && '✅' || '⏭️' }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Subset-fonts | ${{ needs.build.result == 'success' && '✅' || '⏭️' }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Build | ${{ needs.build.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Deploy EdgeOne | ${{ needs.deploy-edgeone.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Deploy UpYun | ${{ needs.deploy-upyun.result == 'success' && '✅' || '❌' }} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Finalize | ✅ (${finalize_duration}秒) |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "**总计耗时:** ${finalize_duration}秒 (finalize 阶段)" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Job 6: Failure Notification (失败通知)
|
# Job 6: Failure Notification (失败通知)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# 部署计时器 - 记录每个阶段的耗时
|
||||||
|
|
||||||
|
TIMING_FILE="/tmp/deploy_timing.txt"
|
||||||
|
> "$TIMING_FILE"
|
||||||
|
|
||||||
|
start_timer() {
|
||||||
|
echo "START_$1=$(date +%s)" >> "$TIMING_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
end_timer() {
|
||||||
|
echo "END_$1=$(date +%s)" >> "$TIMING_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_summary() {
|
||||||
|
echo "## ⏱️ 部署耗时统计" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| 阶段 | 耗时 |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "|------|------|" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
total_start=$(grep "START_WORKFLOW" "$TIMING_FILE" | cut -d'=' -f2)
|
||||||
|
total_end=$(date +%s)
|
||||||
|
total_duration=$((total_end - total_start))
|
||||||
|
|
||||||
|
# 解析每个阶段
|
||||||
|
for stage in PRE_CHECK SUBSET_FONTS BUILD DEPLOY_EDGEONE DEPLOY_UPYUN FINALIZE; do
|
||||||
|
start=$(grep "START_${stage}=" "$TIMING_FILE" | cut -d'=' -f2)
|
||||||
|
end=$(grep "END_${stage}=" "$TIMING_FILE" | cut -d'=' -f2)
|
||||||
|
|
||||||
|
if [ -n "$start" ] && [ -n "$end" ]; then
|
||||||
|
duration=$((end - start))
|
||||||
|
minutes=$((duration / 60))
|
||||||
|
seconds=$((duration % 60))
|
||||||
|
echo "| $stage | ${minutes}m ${seconds}s |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
total_minutes=$((total_duration / 60))
|
||||||
|
total_seconds=$((total_duration % 60))
|
||||||
|
echo "| **总计** | **${total_minutes}m ${total_seconds}s** |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
}
|
||||||
Reference in new issue
Block a user