From dd5019142797072351b425a70302ad90a973e24e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 28 Apr 2026 15:58:33 +0200 Subject: [PATCH 1/2] Use `gh pr create` for `update-framework` workflow --- .github/workflows/update-framework.yml | 51 +++++++++++++++++++++----- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/update-framework.yml b/.github/workflows/update-framework.yml index 0c229a5c8..da7cdc7b8 100644 --- a/.github/workflows/update-framework.yml +++ b/.github/workflows/update-framework.yml @@ -15,6 +15,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: write + pull-requests: write jobs: @@ -50,13 +53,41 @@ jobs: run: | composer update wp-cli/wp-cli --with-all-dependencies - - name: Create pull request - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8 - with: - branch: update-framework - base: ${{ github.event.repository.default_branch }} - token: ${{ secrets.ACTIONS_BOT }} - title: Update wp-cli framework - body: "**This is an automated pull-request**\n\nUpdates the `wp-cli/wp-cli` framework to the latest changeset." - labels: scope:framework - commit-message: "Update wp-cli framework" + - name: Commit and Create Pull Request + env: + GH_TOKEN: ${{ secrets.ACTIONS_BOT }} + PR_BODY: | + **This is an automated pull-request** + + Updates the `wp-cli/wp-cli` framework to the latest changeset. + run: | + if [ -n "$(git status --porcelain)" ]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b update-framework + git add composer.json composer.lock + git commit -m "Update wp-cli framework" + + + # Configure git to use the GH_TOKEN for authentication + git config --local credential.helper "" + git config --local credential.https://github.com/.helper "!f() { echo username=x-access-token; echo password=\${GH_TOKEN}; }; f" + + git push -f origin update-framework + + PR_NUMBER=$(gh pr list --head update-framework --json number --jq '.[0].number // empty') + if [ -z "$PR_NUMBER" ]; then + gh pr create \ + --title "Update wp-cli framework" \ + --body "$PR_BODY" \ + --label "scope:framework" \ + --base "${{ github.event.repository.default_branch }}" \ + --head "update-framework" + else + gh pr edit "$PR_NUMBER" \ + --title "Update wp-cli framework" \ + --body "$PR_BODY" \ + --add-label "scope:framework" \ + --base "${{ github.event.repository.default_branch }}" + fi + fi From 34341c9b8e3db13e2299e7a972d24e34e8014548 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 28 Apr 2026 16:54:18 +0200 Subject: [PATCH 2/2] Apply feedback from code review --- .github/workflows/update-framework.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-framework.yml b/.github/workflows/update-framework.yml index da7cdc7b8..88ea8862d 100644 --- a/.github/workflows/update-framework.yml +++ b/.github/workflows/update-framework.yml @@ -28,6 +28,8 @@ jobs: steps: - name: Check out source code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + token: ${{ secrets.ACTIONS_BOT }} - name: Set up PHP environment uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # v2 @@ -68,13 +70,8 @@ jobs: git add composer.json composer.lock git commit -m "Update wp-cli framework" - - # Configure git to use the GH_TOKEN for authentication - git config --local credential.helper "" - git config --local credential.https://github.com/.helper "!f() { echo username=x-access-token; echo password=\${GH_TOKEN}; }; f" - git push -f origin update-framework - + PR_NUMBER=$(gh pr list --head update-framework --json number --jq '.[0].number // empty') if [ -z "$PR_NUMBER" ]; then gh pr create \