Skip to content

Commit 2063d19

Browse files
committed
Adds Github workflow to update homebrew formula in pvsadm tap repository on release
1 parent 1ed5274 commit 2063d19

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

.github/workflows/update-homebrew-formula.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ jobs:
1212
- name: Checkout repository
1313
uses: actions/checkout@v4
1414

15+
- name: Generate GitHub App Token
16+
uses: actions/create-github-app-token@v1
17+
id: app-token
18+
with:
19+
app-id: ${{ vars.APP_ID }}
20+
private-key: ${{ secrets.PRIVATE_KEY }}
21+
owner: ${{ github.repository_owner }}
22+
1523
- name: Get GitHub App User ID and setup the git environment
1624
id: get-user-id
1725
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
@@ -21,17 +29,8 @@ jobs:
2129
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
2230
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>'
2331
24-
- name: Generate GitHub App Token
25-
uses: actions/create-github-app-token@v1
26-
id: app-token
27-
with:
28-
app-id: ${{ vars.APP_ID }}
29-
private-key: ${{ secrets.PRIVATE_KEY }}
30-
owner: ${{ github.repository_owner }}
31-
3232
- name: Update Homebrew formula
3333
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
3534
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3635
run: |
3736
RELEASE_VERSION=${{ github.event.release.tag_name }}

ci/brew_formula_updater.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ if [ "$#" -ne 4 ]; then
2222
exit 1
2323
fi
2424

25-
# Ensure GitHub token and GH CLI token are set
26-
if [[ -z "$GITHUB_TOKEN" || -z "$GH_TOKEN" ]]; then
27-
echo "Error: Required tokens are not set."
25+
# Ensure GitHub app token is set
26+
if [[ -z "$GH_TOKEN" ]]; then
27+
echo "Error: Required token is not set."
2828
exit 1
2929
fi
3030

@@ -146,16 +146,13 @@ fi
146146
# Commit and push updated formula file to remote tap repository
147147
git add "$FORMULA_FILE"
148148
git commit -m "Update formula to version $NEW_VERSION"
149-
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@${BREW_TAP_REPO_URL#https://}
149+
git remote set-url origin https://x-access-token:${GH_TOKEN}@${BREW_TAP_REPO_URL#https://}
150150

151151
if ! git push origin "$BRANCH_NAME"; then
152152
echo "Error: Failed to push branch $BRANCH_NAME"
153153
exit 1
154154
fi
155155

156-
# Need to unset GITHUB_TOKEN for gh cli to use GH_TOKEN instead
157-
unset GITHUB_TOKEN
158-
159156
# Create PR
160157
if gh pr create --head "$BRANCH_NAME" \
161158
--title "Updates formula to version $NEW_VERSION" \

0 commit comments

Comments
 (0)