-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: refactor project configuration and workflows
- Create reset-run-number.yml
- Loading branch information
1 parent
cb431e0
commit 79b0cb1
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# .gitHub/workflows/reset-run-number.yml | ||
name: Reset Run Number | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
workflow_name: | ||
description: '選擇要重置的工作流程' | ||
required: true | ||
type: choice | ||
options: | ||
- 'pytest.yml' | ||
- 'publish.yml' | ||
- 'reset-run-number.yml' | ||
|
||
jobs: | ||
reset: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write | ||
steps: | ||
- name: Reset run number | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const workflow = '${{ github.event.inputs.workflow_name }}'; | ||
console.log(`Resetting run number for workflow: ${workflow}`); | ||
// 獲取所有運行 | ||
const runs = await github.rest.actions.listWorkflowRuns({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
workflow_id: workflow, | ||
}); | ||
// 刪除所有運行 | ||
console.log(`Found ${runs.data.total_count} runs to delete`); | ||
for (const run of runs.data.workflow_runs) { | ||
console.log(`Deleting run #${run.run_number}`); | ||
await github.rest.actions.deleteWorkflowRun({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: run.id | ||
}); | ||
} | ||
console.log('All runs deleted. Next run will start from #1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters