From fa7ade4c9a97e0fd3f652580a4255583ba23d752 Mon Sep 17 00:00:00 2001 From: Oscaner Miao Date: Fri, 12 Jan 2024 09:26:37 +0800 Subject: [PATCH] fix(#49): github api rate limit in actions --- .github/actions/bump-casks/action.yml | 8 ++++++-- .github/actions/bump-casks/script.sh | 3 ++- .github/actions/bump-formulas/action.yml | 8 ++++++-- .github/actions/bump-formulas/script.sh | 3 ++- .github/actions/homebrew-env/action.yml | 14 +++++++++++++- .github/workflows/main.yml | 4 +++- Formula/alist-cli.rb | 12 ++++++------ 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/.github/actions/bump-casks/action.yml b/.github/actions/bump-casks/action.yml index 5080082..e70e007 100644 --- a/.github/actions/bump-casks/action.yml +++ b/.github/actions/bump-casks/action.yml @@ -14,7 +14,11 @@ runs: env: HOMEBREW_GITHUB_API_TOKEN: ${{ inputs.HOMEBREW_GITHUB_API_TOKEN }} shell: bash + # https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-authenticated-users + # Github Actions: 5000 requests per hour + # 1 * 60 * 24 = 1440 (because bump-pr will checkout a new branch and push to remote) + # 1 concurrent parallel jobs, 1 second delay between jobs. run: | - parallel -j0 --group --halt now,fail=1 \ - './.github/actions/bump-casks/script.sh {}' \ + parallel -j1 --delay 1s --group --halt now,fail=1 \ + "./.github/actions/bump-casks/script.sh {}" \ ::: $(ls $(brew --repository brewforge/chinese)/Casks/*.rb | xargs -I {} basename {} .rb) diff --git a/.github/actions/bump-casks/script.sh b/.github/actions/bump-casks/script.sh index 4a58d31..c153ff3 100755 --- a/.github/actions/bump-casks/script.sh +++ b/.github/actions/bump-casks/script.sh @@ -27,6 +27,7 @@ toV=${cleanCheck#*==>} echo "Updating $cask from $fromV to $toV" if [[ "$fromV" != "$toV" ]]; then - brew bump-cask-pr "$cask" --version "$toV" --verbose --force + brew bump-cask-pr "$cask" --version "$toV" \ + --verbose --force --no-browse --fork-org Brewforge-Bot fi echo "Done for $cask" diff --git a/.github/actions/bump-formulas/action.yml b/.github/actions/bump-formulas/action.yml index e7077ec..2fc2eda 100644 --- a/.github/actions/bump-formulas/action.yml +++ b/.github/actions/bump-formulas/action.yml @@ -14,7 +14,11 @@ runs: env: HOMEBREW_GITHUB_API_TOKEN: ${{ inputs.HOMEBREW_GITHUB_API_TOKEN }} shell: bash + # https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-authenticated-users + # Github Actions: 5000 requests per hour + # 1 * 60 * 24 = 1440 (because bump-pr will checkout a new branch and push to remote) + # 1 concurrent parallel jobs, 1 second delay between jobs. run: | - parallel -j0 --group --halt now,fail=1 \ - './.github/actions/bump-formulas/script.sh {}' \ + parallel -j1 --delay 1s --group --halt now,fail=1 \ + "./.github/actions/bump-formulas/script.sh {}" \ ::: $(ls $(brew --repository brewforge/chinese)/Formula/*.rb | xargs -I {} basename {} .rb) diff --git a/.github/actions/bump-formulas/script.sh b/.github/actions/bump-formulas/script.sh index 36c7870..1dbce67 100755 --- a/.github/actions/bump-formulas/script.sh +++ b/.github/actions/bump-formulas/script.sh @@ -27,6 +27,7 @@ toV=${cleanCheck#*==>} echo "Updating $formula from $fromV to $toV" if [[ "$fromV" != "$toV" ]]; then - brew bump-formula-pr "$formula" --version "$toV" --verbose --force + brew bump-formula-pr "$formula" --version "$toV" \ + --verbose --force --no-browse --fork-org Brewforge-Bot fi echo "Done for $formula" diff --git a/.github/actions/homebrew-env/action.yml b/.github/actions/homebrew-env/action.yml index 977d4d1..24a676a 100644 --- a/.github/actions/homebrew-env/action.yml +++ b/.github/actions/homebrew-env/action.yml @@ -9,6 +9,12 @@ runs: using: 'composite' steps: + - name: git context + shell: bash + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Set up Homebrew id: set-up-homebrew uses: Homebrew/actions/setup-homebrew@master @@ -17,13 +23,16 @@ runs: cask: true test-bot: false - - name: Add parallel cli + - name: Necessary clis shell: bash run: | brew install parallel # makesure brew livecheck works brew livecheck parallel + brew install coreutils + brew link --overwrite coreutils + - name: Add Tap env: HOMEBREW_GITHUB_API_TOKEN: ${{ inputs.HOMEBREW_GITHUB_API_TOKEN }} @@ -32,3 +41,6 @@ runs: brew tap brewforge/chinese brew update brew install ripgrep sd + brew install-bundler-gems --groups "audit,style" + + brew update-reset $(brew --repository brewforge/chinese) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8db98d2..096e1f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: CI on: pull_request: - branches: [main, bump-*] + branches: [main] push: branches: [fix-*] schedule: @@ -13,6 +13,8 @@ on: # allow run manually workflow_dispatch: {} +permissions: write-all + jobs: casks: name: Bump Casks in parallel diff --git a/Formula/alist-cli.rb b/Formula/alist-cli.rb index 302cd66..2634ce8 100644 --- a/Formula/alist-cli.rb +++ b/Formula/alist-cli.rb @@ -1,11 +1,16 @@ class AlistCli < Formula - desc "A file list program that supports multiple storage, powered by Gin and Solidjs." + desc "File list program that supports multiple storage, powered by Gin and Solidjs" homepage "https://github.com/alist-org/alist" url "https://github.com/alist-org/alist/archive/refs/tags/v3.29.1.tar.gz", verified: "mirror.ghproxy.com/" sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" license "AGPL-3.0" head "https://github.com/alist-org/alist.git", branch: "main" + livecheck do + url :stable + strategy :github_latest + end + bottle do sha256 cellar: :any_skip_relocation, arm64_sonoma: "78b6d3071b6ef8afbb8d2c3c4fdc88627f1e0e1fa61e76675fd4731596c2c965" sha256 cellar: :any_skip_relocation, arm64_ventura: "78b6d3071b6ef8afbb8d2c3c4fdc88627f1e0e1fa61e76675fd4731596c2c965" @@ -18,11 +23,6 @@ class AlistCli < Formula sha256 cellar: :any_skip_relocation, x86_64_linux: "81f66e521fe48cb18daadab2d175116201d3ef6b5d5d7bbac1835493eb6e1c81" end - livecheck do - url :stable - strategy :github_latest - end - def install bin.install "alist" end