Skip to content

Commit

Permalink
fix(#49): github api rate limit in actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscaner committed Jan 12, 2024
1 parent b610164 commit b26b7f5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
11 changes: 8 additions & 3 deletions .github/actions/bump-casks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ 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 {}' \
::: $(ls $(brew --repository brewforge/chinese)/Casks/*.rb | xargs -I {} basename {} .rb)
cd $(brew --repository brewforge/chinese)
parallel -j1 --delay 1s --group --halt now,fail=1 \
"$GITHUB_WORKSPACE/.github/actions/bump-casks/script.sh {}" \
::: $(ls ./Casks/*.rb | xargs -I {} basename {} .rb)
2 changes: 1 addition & 1 deletion .github/actions/bump-casks/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ 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
fi
echo "Done for $cask"
11 changes: 8 additions & 3 deletions .github/actions/bump-formulas/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ 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 {}' \
::: $(ls $(brew --repository brewforge/chinese)/Formula/*.rb | xargs -I {} basename {} .rb)
cd $(brew --repository brewforge/chinese)
parallel -j1 --delay 1s --group --halt now,fail=1 \
"$GITHUB_WORKSPACE/.github/actions/bump-formulas/script.sh {}" \
::: $(ls ./Formula/*.rb | xargs -I {} basename {} .rb)
2 changes: 1 addition & 1 deletion .github/actions/bump-formulas/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ 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
fi
echo "Done for $formula"
8 changes: 7 additions & 1 deletion .github/actions/homebrew-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,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 }}
Expand All @@ -32,3 +35,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)
12 changes: 7 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
pull_request:
branches: [main, bump-*]
branches: [main]
push:
branches: [fix-*]
schedule:
Expand All @@ -13,6 +13,8 @@ on:
# allow run manually
workflow_dispatch: {}

permissions: write-all

jobs:
casks:
name: Bump Casks in parallel
Expand All @@ -30,12 +32,12 @@ jobs:
- name: Homebrew env
uses: ./.github/actions/homebrew-env
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Bump casks
uses: ./.github/actions/bump-casks
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

formulas:
name: Bump Formulas in parallel
Expand All @@ -53,9 +55,9 @@ jobs:
- name: Homebrew env
uses: ./.github/actions/homebrew-env
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Bump formulas
uses: ./.github/actions/bump-formulas
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit b26b7f5

Please sign in to comment.