Excavator #1502
This file contains hidden or 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
| name: Excavator | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "25 */4 * * *" | |
| concurrency: | |
| group: excavator-workflow-${{ github.ref }} | |
| jobs: | |
| excavate: | |
| name: Excavate | |
| runs-on: windows-latest | |
| env: | |
| # github_pat_x,github_pat_y | |
| TOKEN_POOL: ${{ secrets.TOKEN_POOL }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install module | |
| env: | |
| PS_MODULE_LIST: ${{ secrets.PS_MODULE_LIST }} | |
| shell: pwsh | |
| run: $env:PS_MODULE_LIST -split ',' | ForEach-Object { Install-Module $_ -Repository PSGallery -Force } | |
| - name: Get latest changes | |
| run: git pull | |
| - name: Excavate | |
| uses: ScoopInstaller/GithubActions@main | |
| # uses: abgox/ScoopInstaller-GithubActions@main | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SCOOP_BRANCH: develop | |
| SKIP_UPDATED: 1 | |
| THROW_ERROR: 0 | |
| - name: Check rate limit | |
| shell: pwsh | |
| run: | | |
| $headers = @{ "Accept" = "application/vnd.github.v3+json" } | |
| Write-Output "::group::GitHub API Rate Limits" | |
| $tokens = $env:TOKEN_POOL.Split(',') | |
| foreach ($i in 1..$tokens.Count) { | |
| $t = $tokens[$i - 1] | |
| $headers["Authorization"] = "token $t" | |
| try { | |
| $response = Invoke-RestMethod -Uri "https://api.github.com/rate_limit" -Headers $headers | |
| Write-Output $response.rate | |
| } | |
| catch { | |
| Write-Output "Token $i : Failed to check rate limit" | |
| } | |
| } | |
| Write-Output "::endgroup::" | |
| check-scoop-version: | |
| runs-on: windows-latest | |
| outputs: | |
| ScoopNewVersion: ${{ steps.scoop-new-version.outputs.ScoopNewVersion }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Check Scoop Version | |
| id: scoop-new-version | |
| shell: pwsh | |
| run: | | |
| .\bin\check-scoop-version.ps1 | |
| - name: Reopen Issue | |
| if: steps.scoop-new-version.outputs.ScoopNewVersion != '' | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| try { | |
| const issue = await github.rest.issues.get({ | |
| issue_number: 8, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo | |
| }); | |
| if (issue.data.state === 'closed') { | |
| await github.rest.issues.update({ | |
| issue_number: 8, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open' | |
| }); | |
| console.log('Issue #8 已重新打开'); | |
| } else { | |
| console.log('Issue #8 已是打开状态'); | |
| } | |
| } catch (error) { | |
| console.error('重新打开 Issue 失败:', error); | |
| throw error; | |
| } |