diff --git a/.github/workflows/update-homebrew-formula.yml b/.github/workflows/update-homebrew-formula.yml index 933e703d..be925cc1 100644 --- a/.github/workflows/update-homebrew-formula.yml +++ b/.github/workflows/update-homebrew-formula.yml @@ -12,6 +12,14 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Generate GitHub App Token + uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + - name: Get GitHub App User ID and setup the git environment id: get-user-id run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" @@ -21,17 +29,8 @@ jobs: git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' - - name: Generate GitHub App Token - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.APP_ID }} - private-key: ${{ secrets.PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - - name: Update Homebrew formula env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} GH_TOKEN: ${{ steps.app-token.outputs.token }} run: | RELEASE_VERSION=${{ github.event.release.tag_name }} diff --git a/ci/brew_formula_updater.sh b/ci/brew_formula_updater.sh index 733eb485..3df63e07 100755 --- a/ci/brew_formula_updater.sh +++ b/ci/brew_formula_updater.sh @@ -22,9 +22,9 @@ if [ "$#" -ne 4 ]; then exit 1 fi -# Ensure GitHub token and GH CLI token are set -if [[ -z "$GITHUB_TOKEN" || -z "$GH_TOKEN" ]]; then - echo "Error: Required tokens are not set." +# Ensure GitHub app token is set +if [[ -z "$GH_TOKEN" ]]; then + echo "Error: Required token is not set." exit 1 fi @@ -146,16 +146,13 @@ fi # Commit and push updated formula file to remote tap repository git add "$FORMULA_FILE" git commit -m "Update formula to version $NEW_VERSION" -git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@${BREW_TAP_REPO_URL#https://} +git remote set-url origin https://x-access-token:${GH_TOKEN}@${BREW_TAP_REPO_URL#https://} if ! git push origin "$BRANCH_NAME"; then echo "Error: Failed to push branch $BRANCH_NAME" exit 1 fi -# Need to unset GITHUB_TOKEN for gh cli to use GH_TOKEN instead -unset GITHUB_TOKEN - # Create PR if gh pr create --head "$BRANCH_NAME" \ --title "Updates formula to version $NEW_VERSION" \