Skip to content

Commit

Permalink
fix(#49): github actions permission denied
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscaner committed Jan 13, 2024
1 parent 5cc9338 commit ad06f9a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 42 deletions.
9 changes: 7 additions & 2 deletions .github/actions/bump-casks/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 --fork-org Brewforge-Bot
fi
echo "Done for $cask"
9 changes: 7 additions & 2 deletions .github/actions/bump-formulas/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 --fork-org Brewforge-Bot
fi
echo "Done for $formula"
23 changes: 13 additions & 10 deletions .github/actions/homebrew-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ runs:

steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: true
cask: true
test-bot: false
shell: bash
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
touch $HOME/.bash_profile
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> $HOME/.bash_profile
eval "$(/usr/local/bin/brew shellenv)"
brew help
- name: Add parallel cli
- name: Necessary clis
shell: bash
run: |
brew install parallel
# makesure brew livecheck works
brew livecheck parallel
brew install parallel coreutils
brew unlink coreutils && brew link coreutils
- name: Add Tap
env:
Expand All @@ -32,3 +34,4 @@ runs:
brew tap brewforge/chinese
brew update
brew install ripgrep sd
brew install-bundler-gems --groups "audit,style"
54 changes: 28 additions & 26 deletions .github/workflows/main.yml → .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: CI
name: schedule

on:
pull_request:
branches: [main, bump-*]
# pull_request:
# branches: [main]
push:
branches: [fix-*]
schedule:
Expand All @@ -11,31 +11,33 @@ on:
# Every day at 6am
- cron: "0 6 * * *"
# allow run manually
workflow_dispatch: {}
workflow_dispatch:

jobs:
casks:
name: Bump Casks in parallel
if: github.repository == 'brewforge/homebrew-chinese'
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest]

steps:
# checkout myself.
- uses: actions/checkout@v3
permissions: write-all

- name: Homebrew env
uses: ./.github/actions/homebrew-env
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

- name: Bump casks
uses: ./.github/actions/bump-casks
with:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
jobs:
# casks:
# name: Bump Casks in parallel
# if: github.repository == 'brewforge/homebrew-chinese'
# runs-on: ${{ matrix.os }}

# strategy:
# matrix:
# os: [macos-latest]

# steps:
# # checkout myself.
# - uses: actions/checkout@v3

# - name: Homebrew env
# uses: ./.github/actions/homebrew-env
# with:
# HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}

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

formulas:
name: Bump Formulas in parallel
Expand Down

0 comments on commit ad06f9a

Please sign in to comment.