diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fd63e5e2e5312e..34b8153af9ce26 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,16 +2,16 @@ https://github.com/WordPress/gutenberg/blob/trunk/CONTRIBUTING.md --> ## What? - + ## Why? ## How? - + ## Testing Instructions - + @@ -20,3 +20,7 @@ https://github.com/WordPress/gutenberg/blob/trunk/CONTRIBUTING.md --> ## Screenshots or screencast + + + + diff --git a/.github/workflows/php-changes-detection.yml b/.github/workflows/php-changes-detection.yml index 7e80157d0caf7c..6196f6810d2cec 100644 --- a/.github/workflows/php-changes-detection.yml +++ b/.github/workflows/php-changes-detection.yml @@ -1,13 +1,13 @@ name: OPTIONAL - Confirm if PHP changes require backporting to WordPress Core on: - pull_request: + pull_request_target: types: [opened, synchronize] jobs: detect_php_changes: name: Detect PHP changes runs-on: ubuntu-latest - if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request' }} + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request_target' }} steps: - name: Check out code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -41,7 +41,7 @@ jobs: uses: peter-evans/find-comment@v2 id: find-comment with: - issue-number: ${{ github.event.pull_request.number }} + issue-number: ${{ github.event.number }} comment-author: 'github-actions[bot]' body-includes: '' @@ -49,7 +49,7 @@ jobs: if: steps.find-comment.outputs.comment-id == '' && steps.changed-files-php.outputs.any_changed == 'true' uses: peter-evans/create-or-update-comment@v3 with: - issue-number: ${{ github.event.pull_request.number }} + issue-number: ${{ github.event.number }} body: | This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. @@ -70,7 +70,7 @@ jobs: uses: peter-evans/create-or-update-comment@v3 with: comment-id: ${{ steps.find-comment.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} + issue-number: ${{ github.event.number }} edit-mode: replace body: | @@ -92,7 +92,7 @@ jobs: uses: peter-evans/create-or-update-comment@v3 with: comment-id: ${{ steps.find-comment.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} + issue-number: ${{ github.event.number }} edit-mode: replace body: | diff --git a/.github/workflows/pull-request-playground-comment.yml b/.github/workflows/pull-request-playground-comment.yml new file mode 100644 index 00000000000000..f5794f9da5fe60 --- /dev/null +++ b/.github/workflows/pull-request-playground-comment.yml @@ -0,0 +1,69 @@ +# Leaves a comment on a pull request with a link to test the changes in a WordPress Playground instance. +name: OPTIONAL - Comment on a pull request with Playground details + +on: + pull_request_target: + types: + - opened + +jobs: + test_using_wordpress_playground: + name: Test using WordPress Playground + runs-on: ubuntu-latest + permissions: + issues: write + if: ${{ github.repository == 'WordPress/gutenberg' || github.event_name == 'pull_request_target' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Update PR Description + uses: actions/github-script@v6 + with: + script: | + // Extract information about the pull request + const prNumber = github.event.number; + + // Fetch the current PR description + const currentDescription = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + }).then(response => response.data.body); + + // Define the start and end comments + const startComment = ''; + const endComment = '; + + // Find the positions of the start and end comments + const startIndex = currentDescription.indexOf(startComment); + const endIndex = currentDescription.indexOf(endComment); + + // Check if both start and end comments are present + if (startIndex !== -1 && endIndex !== -1) { + // Extract the content between the start and end comments + const placeholderContent = currentDescription.slice(startIndex + startComment.length, endIndex); + + // Replace the content with your updated content + const newContent = `## Test this pull request with WordPress Playground + | :arrow_forward: **[Click here to load this PR into WordPress Playground](https://playground.wordpress.net/gutenberg.html?pr=56964)** | + | ------------- | + + > [!TIP] + > _WordPress Playground uses the latest build of Gutenberg from this pull request. If your changes are not reflected in WordPress Playground , it's likely that the most recent build isn't complete or has failed. Check the [build workflow runs to be sure](https://github.com/WordPress/gutenberg/actions/workflows/build-plugin-zip.yml)._ + + Read more about [WordPress Playground](https://developer.wordpress.org/playground/) and its [limitations](https://wordpress.github.io/wordpress-playground/limitations/). + `; + + const newDescription = currentDescription.replace(`${startComment}${placeholderContent}${endComment}`, `${startComment}${newContent}${endComment}`); + + // Update PR description using GitHub API + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + body: newDescription, + }); + } else { + console.log("Start or end comment not found in the PR description."); + } diff --git a/lib/demo.php b/lib/demo.php index 11272050bf4c2e..5d33d62775ddb8 100644 --- a/lib/demo.php +++ b/lib/demo.php @@ -61,4 +61,5 @@ function gutenberg_default_demo_title( $title ) { return $title; } + add_filter( 'default_title', 'gutenberg_default_demo_title' );