Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post a Playground link on every PR using the pull_request_target workflow #5737

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions .github/workflows/pull-request-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ name: Pull Request Comments
on:
pull_request_target:
types: [ 'opened' ]
workflow_dispatch:
inputs:
pr_number:
description: 'The pull request number to process.'
required: true
type: string
branches:
- trunk


# 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_target' && github.head_ref || github.event_name == 'workflow_dispatch' && inputs.pr_number || github.sha }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.event_name == 'workflow_dispatch' && github.event.number || github.sha }}

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
Expand All @@ -31,7 +27,6 @@ jobs:
pull-requests: write
timeout-minutes: 5
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' }}

steps:
- uses: wow-actions/welcome@72817eb31cda1de60f51893d80e2e82ce57f7e76 # v1.3.0
with:
Expand Down Expand Up @@ -87,7 +82,7 @@ jobs:
permissions:
issues: write
pull-requests: write
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'workflow_dispatch' }}
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' }}
steps:
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
Expand All @@ -96,7 +91,7 @@ jobs:
const commentInfo = {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.inputs.pr_number
issue_number: ${{ github.event.number }}
};
const comments = ( await github.rest.issues.listComments( commentInfo ) ).data;

Expand All @@ -122,7 +117,7 @@ jobs:

For more details about these limitations and more, check out the [Limitations page](https://wordpress.github.io/wordpress-playground/limitations/) in the WordPress Playground documentation.

[Test this pull request with WordPress Playground](https://playground.wordpress.net/wordpress.html?pr=${ context.payload.inputs.pr_number }).
[Test this pull request with WordPress Playground](https://playground.wordpress.net/wordpress.html?pr=${{ github.event.number }}).
`;

github.rest.issues.createComment( commentInfo );
30 changes: 2 additions & 28 deletions .github/workflows/test-build-processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,40 +106,14 @@ jobs:
os: ${{ matrix.os }}
directory: ${{ matrix.directory }}

# Calls the Pull Request Commenting workflow to leave a comment detailing how to test the PR within WordPress Playground.
playground-comment:
name: Leave WordPress Playground details
runs-on: ubuntu-latest
permissions:
actions: write
continue-on-error: true
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }}

steps:
- name: Dispatch workflow run
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'pull-request-comments.yml',
ref: 'trunk',
inputs: {
pr_number: '${{ github.event.number }}'
}
});

slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
permissions:
actions: read
contents: read
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos, playground-comment ]
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
Expand All @@ -154,7 +128,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
actions: write
needs: [ playground-comment ]
needs: [ slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
Expand Down
Loading