|
11 | 11 | - cron: '30 2 * * *' |
12 | 12 | workflow_dispatch: # 允许手动触发 |
13 | 13 | inputs: |
14 | | - skip_update: |
15 | | - description: Skip update check and force skip all operations |
| 14 | + update_mode: |
| 15 | + description: 'Update mode: auto (check hash), force (skip hash check), skip (no update)' |
16 | 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 |
| 17 | + default: auto |
| 18 | + type: choice |
| 19 | + options: |
| 20 | + - auto |
| 21 | + - force |
| 22 | + - skip |
24 | 23 |
|
25 | 24 | jobs: |
26 | 25 | auto-update: |
@@ -59,25 +58,29 @@ jobs: |
59 | 58 | # 检查触发方式和用户输入参数 |
60 | 59 | if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
61 | 60 | echo "Manual trigger detected" |
| 61 | + UPDATE_MODE="${{ github.event.inputs.update_mode }}" |
62 | 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" |
| 63 | + case "$UPDATE_MODE" in |
| 64 | + "skip") |
| 65 | + echo "User chose to skip all operations" |
75 | 66 | echo "skip=true" >> $GITHUB_OUTPUT |
76 | | - else |
77 | | - echo "Update needed, content hash is different or error occurred" |
| 67 | + ;; |
| 68 | + "force") |
| 69 | + echo "User chose to force update, skipping hash check" |
78 | 70 | echo "skip=false" >> $GITHUB_OUTPUT |
79 | | - fi |
80 | | - fi |
| 71 | + ;; |
| 72 | + "auto"|*) |
| 73 | + echo "User chose auto mode, checking for updates..." |
| 74 | + # 使用TypeScript脚本进行哈希差异检查,避免shell参数过长问题 |
| 75 | + if pnpm run diff-hash; then |
| 76 | + echo "No update needed, content hash is the same" |
| 77 | + echo "skip=true" >> $GITHUB_OUTPUT |
| 78 | + else |
| 79 | + echo "Update needed, content hash is different or error occurred" |
| 80 | + echo "skip=false" >> $GITHUB_OUTPUT |
| 81 | + fi |
| 82 | + ;; |
| 83 | + esac |
81 | 84 | else |
82 | 85 | echo "Scheduled trigger detected, checking for updates..." |
83 | 86 | # 使用TypeScript脚本进行哈希差异检查,避免shell参数过长问题 |
|
0 commit comments