Skip to content

Commit 642b5b2

Browse files
committed
feat(workflow): 增加手动触发时的跳过和强制更新选项
- 支持workflow_dispatch触发时输入参数skip_update控制跳过更新检测 - 支持workflow_dispatch触发时输入参数force_update控制强制进行更新 - 根据输入参数决定是否跳过hash差异检查或强制执行更新操作 - 保持定时任务触发时自动执行hash差异检查逻辑不变 - 优化日志输出,区分手动触发和定时触发时的处理流程
1 parent a5d63a7 commit 642b5b2

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

.github/workflows/auto-update.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ on:
1010
# 每天UTC 2:30执行(避开高峰期)
1111
- cron: '30 2 * * *'
1212
workflow_dispatch: # 允许手动触发
13+
inputs:
14+
skip_update:
15+
description: Skip update check and force skip all operations
16+
required: false
17+
default: 'false'
18+
type: boolean
19+
force_update:
20+
description: Force update even if no changes detected
21+
required: false
22+
default: 'false'
23+
type: boolean
1324

1425
jobs:
1526
auto-update:
@@ -45,13 +56,38 @@ jobs:
4556
- name: Check if update is needed
4657
id: check-update
4758
run: |
48-
# 使用TypeScript脚本进行哈希差异检查,避免shell参数过长问题
49-
if pnpm run diff-hash; then
50-
echo "No update needed, content hash is the same"
51-
echo "skip=true" >> $GITHUB_OUTPUT
59+
# 检查触发方式和用户输入参数
60+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
61+
echo "Manual trigger detected"
62+
63+
# 检查用户是否选择跳过更新
64+
if [ "${{ github.event.inputs.skip_update }}" = "true" ]; then
65+
echo "User chose to skip update check, skipping all operations"
66+
echo "skip=true" >> $GITHUB_OUTPUT
67+
elif [ "${{ github.event.inputs.force_update }}" = "true" ]; then
68+
echo "User chose to force update, skipping hash check"
69+
echo "skip=false" >> $GITHUB_OUTPUT
70+
else
71+
echo "User chose default behavior, checking for updates..."
72+
# 使用TypeScript脚本进行哈希差异检查,避免shell参数过长问题
73+
if pnpm run diff-hash; then
74+
echo "No update needed, content hash is the same"
75+
echo "skip=true" >> $GITHUB_OUTPUT
76+
else
77+
echo "Update needed, content hash is different or error occurred"
78+
echo "skip=false" >> $GITHUB_OUTPUT
79+
fi
80+
fi
5281
else
53-
echo "Update needed, content hash is different or error occurred"
54-
echo "skip=false" >> $GITHUB_OUTPUT
82+
echo "Scheduled trigger detected, checking for updates..."
83+
# 使用TypeScript脚本进行哈希差异检查,避免shell参数过长问题
84+
if pnpm run diff-hash; then
85+
echo "No update needed, content hash is the same"
86+
echo "skip=true" >> $GITHUB_OUTPUT
87+
else
88+
echo "Update needed, content hash is different or error occurred"
89+
echo "skip=false" >> $GITHUB_OUTPUT
90+
fi
5591
fi
5692
5793
- name: Fetch USB IDs

0 commit comments

Comments
 (0)