diff --git a/.github/actions/bump-casks/action.yml b/.github/actions/bump-casks/action.yml index 5080082..718ca4c 100644 --- a/.github/actions/bump-casks/action.yml +++ b/.github/actions/bump-casks/action.yml @@ -12,9 +12,14 @@ runs: - name: Bump outdated casks # continue-on-error: true env: + HOMEBREW_DEVELOPER: '1' 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..a3d73ab 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 + HOMEBREW_GITHUB_API_TOKEN=$HOMEBREW_GITHUB_API_TOKEN \ + brew bump-cask-pr "$cask" --version "$toV" --verbose --force --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..9dac75b 100644 --- a/.github/actions/bump-formulas/action.yml +++ b/.github/actions/bump-formulas/action.yml @@ -12,9 +12,14 @@ runs: - name: Bump outdated formulas # continue-on-error: true env: + HOMEBREW_DEVELOPER: '1' 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..744350e 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 + HOMEBREW_GITHUB_API_TOKEN=$HOMEBREW_GITHUB_API_TOKEN \ + brew bump-formula-pr "$formula" --version "$toV" --verbose --force --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..f862262 100644 --- a/.github/actions/homebrew-env/action.yml +++ b/.github/actions/homebrew-env/action.yml @@ -9,6 +9,12 @@ runs: using: 'composite' steps: + - name: Set up git info + shell: bash + run: | + git config --global user.name "Homebrew Scheduler" + 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 @@ -16,14 +22,22 @@ runs: core: true cask: true test-bot: false + token: ${{ inputs.HOMEBREW_GITHUB_API_TOKEN }} - - name: Add parallel cli + # Homebrew/actions/setup-homebrew will checkout the main branch. + # re-checkout myself. + - uses: actions/checkout@v3 + + - 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 +46,4 @@ runs: brew tap brewforge/chinese brew update brew install ripgrep sd + brew install-bundler-gems --groups "audit,style" diff --git a/.github/workflows/main.yml b/.github/workflows/schedule.yml similarity index 93% rename from .github/workflows/main.yml rename to .github/workflows/schedule.yml index 8db98d2..761690e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/schedule.yml @@ -1,8 +1,8 @@ -name: CI +name: schedule on: - pull_request: - branches: [main, bump-*] + # pull_request: + # branches: [main] push: branches: [fix-*] schedule: @@ -11,7 +11,9 @@ on: # Every day at 6am - cron: "0 6 * * *" # allow run manually - workflow_dispatch: {} + workflow_dispatch: + +permissions: write-all jobs: casks: