From 23a4e9dbfadea040767751d7af444aa392aece5d Mon Sep 17 00:00:00 2001 From: Matthew Pope <81593196+popematt@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:04:43 -0800 Subject: [PATCH] Update workflow to open a PR instead of directly pushing to main (#15) --- .github/workflows/update-formula.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-formula.yml b/.github/workflows/update-formula.yml index 9b9d336..4067ce6 100644 --- a/.github/workflows/update-formula.yml +++ b/.github/workflows/update-formula.yml @@ -18,6 +18,9 @@ jobs: # Don't run the cron schedule in forks if: github.repository == 'amazon-ion/homebrew-ion-cli' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write steps: - uses: actions/checkout@v4 - shell: bash @@ -47,9 +50,13 @@ jobs: -e 's/ sha256 .*/ sha256 "'"$sha"'"/g' \ -e 's/ version .*/ version "'"$version"'"/g' Formula/ion-cli.rb - git config user.name github-actions - git config user.email github-actions@github.com + # TODO: Use the bot token for pushing so that the PR can be auto-approved and merged. + git config user.name amazon-ion-bot + git config user.email ion-team+amazon-ion-bot@amazon.com + git checkout -b "formula-update-$version" git add -u git commit -m "Update ion-cli formula to $tag" - git push + # In case this is a re-run, we're going to force push + git push --force --set-upstream origin "formula-update-$version" + gh pr create --fill fi