From 3a4a3aa6556edb39807eef6f4cbe2d17354bad5a Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:07:39 -0400 Subject: [PATCH 01/10] Add a workflow that generates a commit message. --- .../workflows/detect-gutenberg-sha-change.yml | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 .github/workflows/detect-gutenberg-sha-change.yml diff --git a/.github/workflows/detect-gutenberg-sha-change.yml b/.github/workflows/detect-gutenberg-sha-change.yml new file mode 100644 index 0000000000000..91c44ab0f52c1 --- /dev/null +++ b/.github/workflows/detect-gutenberg-sha-change.yml @@ -0,0 +1,170 @@ +# Generates a list of changes and a commit message when the pinned gutenberg repository hash changes. +name: Generate changelog and commit message + +on: + # This workflow was introduced in WordPress 7.0. + pull_request: + branches: + - trunk + - '[7-9].[0-9]' + paths: + - 'package.json' + +# Cancels all previous workflow runs for pull requests that have not completed. +concurrency: + # The concurrency group contains the workflow name and the branch name for pull requests + # or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +# Disable permissions for all available scopes by default. +# Any needed permissions should be configured at the job level. +permissions: {} + +jobs: + # Detects whether the gutenberg.sha value in the package.json file has changed. + # + # Performs the following steps: + # - Checks out the repository. + # - Check if the pinned hash has changed. + detect-hash-change: + name: Detect Gutenberg SHA change + runs-on: ubuntu-24.04 + if: ${{ github.repository == 'wordpress/wordpress-develop' }} + permissions: + contents: read + outputs: + sha_changed: ${{ steps.check-sha.outputs.sha_changed }} + base_sha: ${{ steps.check-sha.outputs.base_sha }} + head_sha: ${{ steps.check-sha.outputs.head_sha }} + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Check if the pinned Gutenberg hash has changed + id: check-sha + run: | + BASE_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.base.sha }}:package.json | jq -r '.gutenberg.sha // empty') + HEAD_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.head.sha }}:package.json | jq -r '.gutenberg.sha // empty') + + echo "base_sha=$BASE_GUTENBERG_SHA" >> "$GITHUB_OUTPUT" + echo "head_sha=$HEAD_GUTENBERG_SHA" >> "$GITHUB_OUTPUT" + + if [ "$BASE_GUTENBERG_SHA" != "$HEAD_GUTENBERG_SHA" ]; then + echo "sha_changed=true" >> "$GITHUB_OUTPUT" + echo "The pinned Gutenberg Repository hash has changed." + echo " Previous SHA (base branch): $BASE_GUTENBERG_SHA" + echo " New SHA (head branch): $HEAD_GUTENBERG_SHA" + else + echo "sha_changed=false" >> "$GITHUB_OUTPUT" + echo "The pinned Gutenberg repository hash has not changed: $HEAD_GUTENBERG_SHA" + fi + + # Generates a list of changes between two specified hashes. + # + # Performs the following steps: + # - Checks out the repository. + # - Generates a list of changes. + # - Uploads the changelog as an artifact. + generate-changelog: + name: Generate a list of changes between the hashes + runs-on: ubuntu-24.04 + needs: [ 'detect-hash-change' ] + if: ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }} + permissions: + contents: read + outputs: + has_changes: ${{ steps.change-list.outputs.has_changes }} + + steps: + - name: Checkout Gutenberg repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: WordPress/gutenberg + filter: blob:none + fetch-depth: 0 + + - name: Generate a list of changes + id: change-list + env: + BASE_SHA: ${{ needs.detect-hash-change.outputs.base_sha }} + HEAD_SHA: ${{ needs.detect-hash-change.outputs.head_sha }} + run: | + git log --reverse --format="- %s" "$BASE_SHA".."$HEAD_SHA" | \ + sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' \ + > changelog.txt + + if [ -s changelog.txt ]; then + echo "has_changes=true" >> "$GITHUB_OUTPUT" + else + echo "has_changes=false" >> "$GITHUB_OUTPUT" + fi + + - name: Upload changelog as an artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + path: changelog.txt + archive: false + + # Drafts a commit message containing a detailed list of changes being merged. + # + # Performs the following steps: + # - Downloads the changelog artifact. + # - Builds a commit message. + # - Uploads the commit message as an artifact. + generate-commit-message: + name: Generate commit message + runs-on: ubuntu-24.04 + needs: [ 'detect-hash-change', 'generate-changelog' ] + if: ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }} + permissions: + contents: read + + steps: + - name: Download changelog artifact + if: ${{ needs.generate-changelog.outputs.has_changes == 'true' }} + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: changelog.txt + skip-decompress: true + + - name: Build commit message + env: + BASE_SHA: ${{ needs.detect-hash-change.outputs.base_sha }} + HEAD_SHA: ${{ needs.detect-hash-change.outputs.head_sha }} + HAS_CHANGES: ${{ needs.generate-changelog.outputs.has_changes }} + run: | + { + printf 'Editor: Bump pinned hash for the Gutenberg repository.\n\n' + printf "This updates the pinned hash from the gutenberg from \`%s\` to \`%s\`.\n\n" "$BASE_SHA" "$HEAD_SHA" + + if [ "$HAS_CHANGES" = "false" ]; then + printf '> [!WARNING]\n' + printf '> No pull request references were found in the commits between the two hashes. Please verify the hash range is correct.\n\n' + else + printf 'The following changes are included:\n\n' + cat changes.txt + printf '\n\n' + fi + + printf 'A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/%s...%s.\n\n' "$BASE_SHA" "$HEAD_SHA" + printf 'See #64595, #64393.\n' + } > commit-message.md + + - name: Upload commit message as an artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + path: commit-message.md + archive: false + + - name: Post PR comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + REPO: ${{ github.repository }} + run: | + gh pr comment "$PR_NUMBER" --body-file commit-message.md --repo "$REPO" From caa9c37d20b1c82b4b265f4647f815f8a419063f Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:04:10 -0400 Subject: [PATCH 02/10] Bump the hash to test. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5a390aac47174..daa6c643cc442 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://develop.svn.wordpress.org/trunk" }, "gutenberg": { - "sha": "8c78d87453509661a9f28f978ba2c242d515563b", + "sha": "f8c6fa448cbec511feb06cccfb5fad1eedd1818c", "ghcrRepo": "WordPress/gutenberg/gutenberg-wp-develop-build" }, "engines": { From df9bfd8c56333925ee9e15c304ee2dca483a4412 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:16:40 -0400 Subject: [PATCH 03/10] Correct file path. --- .github/workflows/detect-gutenberg-sha-change.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-gutenberg-sha-change.yml b/.github/workflows/detect-gutenberg-sha-change.yml index 91c44ab0f52c1..ebf83f3b5950b 100644 --- a/.github/workflows/detect-gutenberg-sha-change.yml +++ b/.github/workflows/detect-gutenberg-sha-change.yml @@ -147,7 +147,7 @@ jobs: printf '> No pull request references were found in the commits between the two hashes. Please verify the hash range is correct.\n\n' else printf 'The following changes are included:\n\n' - cat changes.txt + cat changelog.txt printf '\n\n' fi From c2b1910ce03fead20b1a28e174e59e357b843778 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:18:39 -0400 Subject: [PATCH 04/10] Remove extra line and update name. --- .github/workflows/detect-gutenberg-sha-change.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detect-gutenberg-sha-change.yml b/.github/workflows/detect-gutenberg-sha-change.yml index ebf83f3b5950b..d8fac415a0699 100644 --- a/.github/workflows/detect-gutenberg-sha-change.yml +++ b/.github/workflows/detect-gutenberg-sha-change.yml @@ -1,5 +1,5 @@ # Generates a list of changes and a commit message when the pinned gutenberg repository hash changes. -name: Generate changelog and commit message +name: Draft commit message on: # This workflow was introduced in WordPress 7.0. @@ -148,7 +148,7 @@ jobs: else printf 'The following changes are included:\n\n' cat changelog.txt - printf '\n\n' + printf '\n' fi printf 'A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/%s...%s.\n\n' "$BASE_SHA" "$HEAD_SHA" From 5b98f2210fcbc671af82caf54a060fa9193aea96 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:19:06 -0400 Subject: [PATCH 05/10] Convert to a reusable workflow pattern. --- .../workflows/detect-gutenberg-sha-change.yml | 128 +----------------- .github/workflows/pull-request-comments.yml | 119 +++++++++++++++- ...usable-detect-gutenberg-hash-change-v1.yml | 55 ++++++++ .../reusable-generate-commit-message-v1.yml | 85 ++++++++++++ ...usable-generate-gutenberg-changelog-v1.yml | 57 ++++++++ 5 files changed, 322 insertions(+), 122 deletions(-) create mode 100644 .github/workflows/reusable-detect-gutenberg-hash-change-v1.yml create mode 100644 .github/workflows/reusable-generate-commit-message-v1.yml create mode 100644 .github/workflows/reusable-generate-gutenberg-changelog-v1.yml diff --git a/.github/workflows/detect-gutenberg-sha-change.yml b/.github/workflows/detect-gutenberg-sha-change.yml index d8fac415a0699..477d672e952f0 100644 --- a/.github/workflows/detect-gutenberg-sha-change.yml +++ b/.github/workflows/detect-gutenberg-sha-change.yml @@ -23,92 +23,20 @@ permissions: {} jobs: # Detects whether the gutenberg.sha value in the package.json file has changed. - # - # Performs the following steps: - # - Checks out the repository. - # - Check if the pinned hash has changed. detect-hash-change: name: Detect Gutenberg SHA change - runs-on: ubuntu-24.04 - if: ${{ github.repository == 'wordpress/wordpress-develop' }} + uses: ./.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml permissions: contents: read - outputs: - sha_changed: ${{ steps.check-sha.outputs.sha_changed }} - base_sha: ${{ steps.check-sha.outputs.base_sha }} - head_sha: ${{ steps.check-sha.outputs.head_sha }} - - steps: - - name: Checkout repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Check if the pinned Gutenberg hash has changed - id: check-sha - run: | - BASE_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.base.sha }}:package.json | jq -r '.gutenberg.sha // empty') - HEAD_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.head.sha }}:package.json | jq -r '.gutenberg.sha // empty') - - echo "base_sha=$BASE_GUTENBERG_SHA" >> "$GITHUB_OUTPUT" - echo "head_sha=$HEAD_GUTENBERG_SHA" >> "$GITHUB_OUTPUT" - - if [ "$BASE_GUTENBERG_SHA" != "$HEAD_GUTENBERG_SHA" ]; then - echo "sha_changed=true" >> "$GITHUB_OUTPUT" - echo "The pinned Gutenberg Repository hash has changed." - echo " Previous SHA (base branch): $BASE_GUTENBERG_SHA" - echo " New SHA (head branch): $HEAD_GUTENBERG_SHA" - else - echo "sha_changed=false" >> "$GITHUB_OUTPUT" - echo "The pinned Gutenberg repository hash has not changed: $HEAD_GUTENBERG_SHA" - fi # Generates a list of changes between two specified hashes. - # - # Performs the following steps: - # - Checks out the repository. - # - Generates a list of changes. - # - Uploads the changelog as an artifact. generate-changelog: name: Generate a list of changes between the hashes - runs-on: ubuntu-24.04 + uses: ./.github/workflows/reusable-generate-gutenberg-changelog-v1.yml needs: [ 'detect-hash-change' ] if: ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }} permissions: contents: read - outputs: - has_changes: ${{ steps.change-list.outputs.has_changes }} - - steps: - - name: Checkout Gutenberg repository - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - repository: WordPress/gutenberg - filter: blob:none - fetch-depth: 0 - - - name: Generate a list of changes - id: change-list - env: - BASE_SHA: ${{ needs.detect-hash-change.outputs.base_sha }} - HEAD_SHA: ${{ needs.detect-hash-change.outputs.head_sha }} - run: | - git log --reverse --format="- %s" "$BASE_SHA".."$HEAD_SHA" | \ - sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' \ - > changelog.txt - - if [ -s changelog.txt ]; then - echo "has_changes=true" >> "$GITHUB_OUTPUT" - else - echo "has_changes=false" >> "$GITHUB_OUTPUT" - fi - - - name: Upload changelog as an artifact - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - path: changelog.txt - archive: false # Drafts a commit message containing a detailed list of changes being merged. # @@ -118,53 +46,11 @@ jobs: # - Uploads the commit message as an artifact. generate-commit-message: name: Generate commit message - runs-on: ubuntu-24.04 + uses: ./.github/workflows/reusable-generate-commit-message-v1.yml needs: [ 'detect-hash-change', 'generate-changelog' ] - if: ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }} + if: ${{ needs.generate-changelog.outputs.has_changes == 'true' }} permissions: contents: read - - steps: - - name: Download changelog artifact - if: ${{ needs.generate-changelog.outputs.has_changes == 'true' }} - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: changelog.txt - skip-decompress: true - - - name: Build commit message - env: - BASE_SHA: ${{ needs.detect-hash-change.outputs.base_sha }} - HEAD_SHA: ${{ needs.detect-hash-change.outputs.head_sha }} - HAS_CHANGES: ${{ needs.generate-changelog.outputs.has_changes }} - run: | - { - printf 'Editor: Bump pinned hash for the Gutenberg repository.\n\n' - printf "This updates the pinned hash from the gutenberg from \`%s\` to \`%s\`.\n\n" "$BASE_SHA" "$HEAD_SHA" - - if [ "$HAS_CHANGES" = "false" ]; then - printf '> [!WARNING]\n' - printf '> No pull request references were found in the commits between the two hashes. Please verify the hash range is correct.\n\n' - else - printf 'The following changes are included:\n\n' - cat changelog.txt - printf '\n' - fi - - printf 'A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/%s...%s.\n\n' "$BASE_SHA" "$HEAD_SHA" - printf 'See #64595, #64393.\n' - } > commit-message.md - - - name: Upload commit message as an artifact - uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 - with: - path: commit-message.md - archive: false - - - name: Post PR comment - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REPO: ${{ github.repository }} - run: | - gh pr comment "$PR_NUMBER" --body-file commit-message.md --repo "$REPO" + with: + previous-hash: ${{ needs.detect-hash-change.outputs.base_sha }} + new-hash: ${{ needs.detect-hash-change.outputs.head_sha }} diff --git a/.github/workflows/pull-request-comments.yml b/.github/workflows/pull-request-comments.yml index da30e2feb7f11..314b0dc3cf8a0 100644 --- a/.github/workflows/pull-request-comments.yml +++ b/.github/workflows/pull-request-comments.yml @@ -5,7 +5,7 @@ on: pull_request_target: types: [ 'opened', 'synchronize', 'reopened', 'edited' ] workflow_run: - workflows: [ 'Test Build Processes' ] + workflows: [ 'Test Build Processes', 'Draft commit message' ] types: - completed @@ -228,3 +228,120 @@ jobs: `, } ); } + + # Adds a comment with a drafted commit message. + drafted-commit-message: + name: Manage commit message draft + runs-on: ubuntu-24.04 + permissions: + issues: write + pull-requests: write + if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' && ! github.event.pull_request.draft && github.event.pull_request.state == 'open' }} + + steps: + - name: Download artifact + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const fs = require( 'fs' ); + + const artifacts = await github.rest.actions.listWorkflowRunArtifacts( { + owner: context.repo.owner, + repo: context.repo.repo, + run_id: process.env.RUN_ID, + } ); + + const matchPrNumberArtifact = artifacts.data.artifacts.filter( ( artifact ) => { + return artifact.name === 'pr-number' + } )[0]; + + if ( ! matchPrNumberArtifact ) { + core.setFailed( 'No PR number artifact found!' ); + return; + } + + const downloadPrNumber = await github.rest.actions.downloadArtifact( { + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchPrNumberArtifact.id, + archive_format: 'zip', + } ); + + fs.writeFileSync( '${{github.workspace}}/pr-number.zip', Buffer.from( downloadPrNumber.data ) ) + + const matchMessageArtifact = artifacts.data.artifacts.filter( ( artifact ) => { + return artifact.name === 'commit-message.md' + } )[0]; + + if ( ! matchMessageArtifact ) { + core.setFailed( 'No commit message artifact found!' ); + return; + } + + const downloadCommitMessage = await github.rest.actions.downloadArtifact( { + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchMessageArtifact.id, + archive_format: 'zip', + } ); + + fs.writeFileSync( '${{github.workspace}}/commit-message.zip', Buffer.from( downloadCommitMessage.data ) ) + env: + RUN_ID: ${{ github.event.workflow_run.id }} + + - name: Unzip the artifact containing the PR number + run: unzip pr-number.zip + + - name: Unzip the artifact containing the commit mesage + run: unzip commit-message.zip + + - name: Leave or update a comment with the commit message draft + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const fs = require( 'fs' ); + const issue_number = Number( fs.readFileSync( './NR' ) ); + + core.info( `Checking pull request #${issue_number}.` ); + + // Confirm that the pull request is still open before leaving a comment. + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: issue_number, + }); + + if ( pr.data.state !== 'open' ) { + core.info( 'The pull request has been closed. No comment will be left.' ); + return; + } + + // Comments are only added once and then updated on future commits. + const commentInfo = { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number, + }; + + const comments = ( await github.rest.issues.listComments( commentInfo ) ).data; + const hasCommitMessageDraft = comments.find( comment => comment.user.type === 'Bot' && comment.body.includes( 'Editor: Bump pinned hash' ) ); + + // Construct comment + commentInfo.body = '## Commit Message Draft\n' + + 'This pull request changes the pinned hash for the Gutenberg repository. Here is a commit message draft containing a compiled list of changes included with additional required information:\n\n' + + ```\n' + + commitMessageContents + + '\n```\n' + + '**Always verify these commit message drafts before using. And don't forget to include props!**'; + + // Only update the comment when there are changes. + if ( hasCommitMessageDraft ) { + if ( hasCommitMessageDraft.body != commentInfo.body ) { + commentInfo.comment_id = hasCommitMessageDraft.id; + + github.rest.issues.updateComment( commentInfo ); + } + return; + } + + github.rest.issues.createComment( commentInfo ); diff --git a/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml b/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml new file mode 100644 index 0000000000000..629f0339926cd --- /dev/null +++ b/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml @@ -0,0 +1,55 @@ +## +# A reusable workflow that detects when the `gutenberg.sha` value changes in the `package.json` file. +## +name: Detect hash change (reusable) + +on: + workflow_call: + +# Disable permissions for all available scopes by default. +# Any needed permissions should be configured at the job level. +permissions: {} + +jobs: + # Detects whether the gutenberg.sha value in the package.json file has changed. + # + # Performs the following steps: + # - Checks out the repository. + # - Check if the pinned hash has changed. + detect-hash-change: + name: Detect Gutenberg SHA change + runs-on: ubuntu-24.04 + if: ${{ github.repository == 'wordpress/wordpress-develop' }} + permissions: + contents: read + timeout-minutes: 5 + outputs: + sha_changed: ${{ steps.check-sha.outputs.sha_changed }} + base_sha: ${{ steps.check-sha.outputs.base_sha }} + head_sha: ${{ steps.check-sha.outputs.head_sha }} + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Check if the pinned Gutenberg hash has changed + id: check-sha + run: | + BASE_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.base.sha }}:package.json | jq -r '.gutenberg.sha // empty') + HEAD_GUTENBERG_SHA=$(git show ${{ github.event.pull_request.head.sha }}:package.json | jq -r '.gutenberg.sha // empty') + + echo "base_sha=$BASE_GUTENBERG_SHA" >> "$GITHUB_OUTPUT" + echo "head_sha=$HEAD_GUTENBERG_SHA" >> "$GITHUB_OUTPUT" + + if [ "$BASE_GUTENBERG_SHA" != "$HEAD_GUTENBERG_SHA" ]; then + echo "sha_changed=true" >> "$GITHUB_OUTPUT" + echo "The pinned Gutenberg Repository hash has changed." + echo " Previous SHA (base branch): $BASE_GUTENBERG_SHA" + echo " New SHA (head branch): $HEAD_GUTENBERG_SHA" + else + echo "sha_changed=false" >> "$GITHUB_OUTPUT" + echo "The pinned Gutenberg repository hash has not changed: $HEAD_GUTENBERG_SHA" + fi diff --git a/.github/workflows/reusable-generate-commit-message-v1.yml b/.github/workflows/reusable-generate-commit-message-v1.yml new file mode 100644 index 0000000000000..cf3363e789add --- /dev/null +++ b/.github/workflows/reusable-generate-commit-message-v1.yml @@ -0,0 +1,85 @@ +## +# A reusable workflow that detects when the `gutenberg.sha` value changes in the `package.json` file. +## +name: Detect hash change (reusable) + +on: + workflow_call: + inputs: + previous-hash: + description: 'The previous commit SHA value.' + required: true + type: 'string' + new-hash: + description: 'The new commit hash value.' + required: true + type: 'string' + +# Disable permissions for all available scopes by default. +# Any needed permissions should be configured at the job level. +permissions: {} + +jobs: + # Drafts a commit message containing a detailed list of changes being merged. + # + # Performs the following steps: + # - Downloads the changelog artifact. + # - Builds a commit message. + # - Uploads the commit message as an artifact. + # - Saves the pull request number to a text file. + # - Uploads the pull request number as an artifact. + generate-commit-message: + name: Generate commit message + runs-on: ubuntu-24.04 + permissions: + contents: read + + steps: + - name: Download changelog artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: changelog.txt + skip-decompress: true + + - name: Build commit message + env: + BASE_SHA: ${{ inputs.previous-hash }} + HEAD_SHA: ${{ inputs.new-hash }} + run: | + { + printf 'Editor: Bump pinned hash for the Gutenberg repository.\n\n' + printf "This updates the pinned hash from the gutenberg from \`%s\` to \`%s\`.\n\n" "$BASE_SHA" "$HEAD_SHA" + + if [ "$HAS_CHANGES" = "false" ]; then + printf '> [!WARNING]\n' + printf '> No pull request references were found in the commits between the two hashes. Please verify the hash range is correct.\n\n' + else + printf 'The following changes are included:\n\n' + cat changelog.txt + printf '\n' + fi + + printf 'A full list of changes can be found on GitHub: https://github.com/WordPress/gutenberg/compare/%s...%s.\n\n' "$BASE_SHA" "$HEAD_SHA" + printf 'See #64595, #64393.\n' + } > commit-message.md + + - name: Upload commit message as an artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: commit-message + path: commit-message.md + + - name: Save PR number + run: | + mkdir -p ./pr-number + echo "${EVENT_NUMBER}" > ./pr-number/NR + env: + EVENT_NUMBER: ${{ github.event.number }} + + # Uploads the PR number as an artifact for the Pull Request Commenting workflow to download and then + # leave a comment detailing how to test the PR within WordPress Playground. + - name: Upload PR number as artifact + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 + with: + name: pr-number + path: pr-number/ diff --git a/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml b/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml new file mode 100644 index 0000000000000..2b11042023e72 --- /dev/null +++ b/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml @@ -0,0 +1,57 @@ +## +# A reusable workflow that detects when the `gutenberg.sha` value changes in the `package.json` file. +## +name: Detect hash change (reusable) + +on: + workflow_call: + +# Disable permissions for all available scopes by default. +# Any needed permissions should be configured at the job level. +permissions: {} + +jobs: + # Generates a list of changes between two specified hashes. + # + # Performs the following steps: + # - Checks out the repository. + # - Generates a list of changes. + # - Uploads the changelog as an artifact. + generate-changelog: + name: Generate a list of changes between the hashes + runs-on: ubuntu-24.04 + permissions: + contents: read + timeout-minutes: 5 + outputs: + has_changes: ${{ steps.change-list.outputs.has_changes }} + + steps: + - name: Checkout Gutenberg repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: WordPress/gutenberg + filter: blob:none + fetch-depth: 0 + + - name: Generate a list of changes + id: change-list + env: + BASE_SHA: ${{ needs.detect-hash-change.outputs.base_sha }} + HEAD_SHA: ${{ needs.detect-hash-change.outputs.head_sha }} + run: | + git log --reverse --format="- %s" "$BASE_SHA".."$HEAD_SHA" | \ + sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' \ + > changelog.txt + + if [ -s changelog.txt ]; then + echo "has_changes=true" >> "$GITHUB_OUTPUT" + else + echo "has_changes=false" >> "$GITHUB_OUTPUT" + fi + + - name: Upload changelog as an artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + path: changelog.txt + archive: false From cbd351173437a0fe7792a23cded6079363c8be29 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:23:32 -0400 Subject: [PATCH 06/10] Update hash. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index daa6c643cc442..93fc00f6a8e69 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://develop.svn.wordpress.org/trunk" }, "gutenberg": { - "sha": "f8c6fa448cbec511feb06cccfb5fad1eedd1818c", + "sha": "4fda7e74c5848136d0b369c8e545fc872ce25edd", "ghcrRepo": "WordPress/gutenberg/gutenberg-wp-develop-build" }, "engines": { From 130bd60f94f4e3b13afc06b64d0423fb479d8426 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:23:58 -0400 Subject: [PATCH 07/10] Revert "Update hash." This reverts commit cbd351173437a0fe7792a23cded6079363c8be29. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93fc00f6a8e69..daa6c643cc442 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://develop.svn.wordpress.org/trunk" }, "gutenberg": { - "sha": "4fda7e74c5848136d0b369c8e545fc872ce25edd", + "sha": "f8c6fa448cbec511feb06cccfb5fad1eedd1818c", "ghcrRepo": "WordPress/gutenberg/gutenberg-wp-develop-build" }, "engines": { From 027b9d094a583f11f27292a0eef944038b5479db Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:39:13 -0400 Subject: [PATCH 08/10] Add inputs and outputs. --- .../workflows/detect-gutenberg-sha-change.yml | 3 +++ ...reusable-detect-gutenberg-hash-change-v1.yml | 10 ++++++++++ ...reusable-generate-gutenberg-changelog-v1.yml | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/detect-gutenberg-sha-change.yml b/.github/workflows/detect-gutenberg-sha-change.yml index 477d672e952f0..07cfc9e687471 100644 --- a/.github/workflows/detect-gutenberg-sha-change.yml +++ b/.github/workflows/detect-gutenberg-sha-change.yml @@ -37,6 +37,9 @@ jobs: if: ${{ needs.detect-hash-change.outputs.sha_changed == 'true' }} permissions: contents: read + with: + base-sha: ${{ needs.detect-hash-change.outputs.base_sha }} + head-sha: ${{ needs.detect-hash-change.outputs.head_sha }} # Drafts a commit message containing a detailed list of changes being merged. # diff --git a/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml b/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml index 629f0339926cd..7abdda4015a80 100644 --- a/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml +++ b/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml @@ -5,6 +5,16 @@ name: Detect hash change (reusable) on: workflow_call: + outputs: + sha_changed: + description: 'Whether the pinned Gutenberg hash has changed.' + value: ${{ jobs.detect-hash-change.outputs.sha_changed }} + base_sha: + description: 'The previous pinned Gutenberg hash.' + value: ${{ jobs.detect-hash-change.outputs.base_sha }} + head_sha: + description: 'The new pinned Gutenberg hash.' + value: ${{ jobs.detect-hash-change.outputs.head_sha }} # Disable permissions for all available scopes by default. # Any needed permissions should be configured at the job level. diff --git a/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml b/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml index 2b11042023e72..7eba4483454a8 100644 --- a/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml +++ b/.github/workflows/reusable-generate-gutenberg-changelog-v1.yml @@ -5,6 +5,19 @@ name: Detect hash change (reusable) on: workflow_call: + inputs: + base-sha: + description: 'The previous pinned Gutenberg hash.' + type: string + required: true + head-sha: + description: 'The new pinned Gutenberg hash.' + type: string + required: true + outputs: + has_changes: + description: 'Whether any pull request-linked changes were found between the two hashes.' + value: ${{ jobs.generate-changelog.outputs.has_changes }} # Disable permissions for all available scopes by default. # Any needed permissions should be configured at the job level. @@ -37,8 +50,8 @@ jobs: - name: Generate a list of changes id: change-list env: - BASE_SHA: ${{ needs.detect-hash-change.outputs.base_sha }} - HEAD_SHA: ${{ needs.detect-hash-change.outputs.head_sha }} + BASE_SHA: ${{ inputs.base-sha }} + HEAD_SHA: ${{ inputs.head-sha }} run: | git log --reverse --format="- %s" "$BASE_SHA".."$HEAD_SHA" | \ sed 's|#\([0-9][0-9]*\)|https://github.com/WordPress/gutenberg/pull/\1|g; /github\.com\/WordPress\/gutenberg\/pull/!d' \ From b5e09c062e0db1694dc562cd5d348701a720aee4 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:43:38 -0400 Subject: [PATCH 09/10] Remove repo check --- .github/workflows/reusable-detect-gutenberg-hash-change-v1.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml b/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml index 7abdda4015a80..bfb51762fd959 100644 --- a/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml +++ b/.github/workflows/reusable-detect-gutenberg-hash-change-v1.yml @@ -29,7 +29,6 @@ jobs: detect-hash-change: name: Detect Gutenberg SHA change runs-on: ubuntu-24.04 - if: ${{ github.repository == 'wordpress/wordpress-develop' }} permissions: contents: read timeout-minutes: 5 From c0b5543d9c3c5941537fd7bb28802f194aef7bab Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Mar 2026 21:44:50 -0400 Subject: [PATCH 10/10] Bump hash. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index daa6c643cc442..6377a1bee9ab0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "url": "https://develop.svn.wordpress.org/trunk" }, "gutenberg": { - "sha": "f8c6fa448cbec511feb06cccfb5fad1eedd1818c", + "sha": "684ad23205876b8c527471a243f3183257027b25", "ghcrRepo": "WordPress/gutenberg/gutenberg-wp-develop-build" }, "engines": {