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 83f553d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
8 changes: 6 additions & 2 deletions .github/actions/bump-casks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion .github/actions/bump-casks/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 --fork-org Brewforge-Bot
fi
echo "Done for $cask"
8 changes: 6 additions & 2 deletions .github/actions/bump-formulas/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion .github/actions/bump-formulas/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 --fork-org Brewforge-Bot
fi
echo "Done for $formula"
18 changes: 17 additions & 1 deletion .github/actions/homebrew-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,13 +23,20 @@ runs:
cask: true
test-bot: false

- 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 }}
Expand All @@ -32,3 +45,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)
4 changes: 3 additions & 1 deletion .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 Down
12 changes: 6 additions & 6 deletions Formula/alist-cli.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 83f553d

Please sign in to comment.