Skip to content

Commit 1850589

Browse files
committed
Build/Test Tools: Fix the workflow that posts a preview link on every Pull Request
Fixes a 403 error in the pull-request-comments.yml job by switching from a custom workflow dispatch call to the pull_request_target trigger. Follow up to [57124], [57174]. Props ockham. See #59416. git-svn-id: https://develop.svn.wordpress.org/trunk@57178 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 13e055c commit 1850589

2 files changed

Lines changed: 8 additions & 40 deletions

File tree

.github/workflows/pull-request-comments.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,14 @@ name: Pull Request Comments
44
on:
55
pull_request_target:
66
types: [ 'opened' ]
7-
workflow_dispatch:
8-
inputs:
9-
pr_number:
10-
description: 'The pull request number to process.'
11-
required: true
12-
type: string
7+
branches:
8+
- trunk
139

1410
# Cancels all previous workflow runs for pull requests that have not completed.
1511
concurrency:
1612
# The concurrency group contains the workflow name and the branch name for pull requests
1713
# or the commit hash for any other events.
18-
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.event_name == 'workflow_dispatch' && inputs.pr_number || github.sha }}
19-
cancel-in-progress: true
14+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.event_name == 'workflow_dispatch' && github.event.number || github.sha }}
2015

2116
# Disable permissions for all available scopes by default.
2217
# Any needed permissions should be configured at the job level.
@@ -31,7 +26,6 @@ jobs:
3126
pull-requests: write
3227
timeout-minutes: 5
3328
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' }}
34-
3529
steps:
3630
- uses: wow-actions/welcome@72817eb31cda1de60f51893d80e2e82ce57f7e76 # v1.3.0
3731
with:
@@ -87,7 +81,7 @@ jobs:
8781
permissions:
8882
issues: write
8983
pull-requests: write
90-
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'workflow_dispatch' }}
84+
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' }}
9185
steps:
9286
- uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
9387
with:
@@ -96,7 +90,7 @@ jobs:
9690
const commentInfo = {
9791
owner: context.repo.owner,
9892
repo: context.repo.repo,
99-
issue_number: context.payload.inputs.pr_number
93+
issue_number: ${{ github.event.number }}
10094
};
10195
const comments = ( await github.rest.issues.listComments( commentInfo ) ).data;
10296
@@ -122,7 +116,7 @@ jobs:
122116
123117
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.
124118
125-
[Test this pull request with WordPress Playground](https://playground.wordpress.net/wordpress.html?pr=${ context.payload.inputs.pr_number }).
119+
[Test this pull request with WordPress Playground](https://playground.wordpress.net/wordpress.html?pr=${{ github.event.number }}).
126120
`;
127121
128122
github.rest.issues.createComment( commentInfo );

.github/workflows/test-build-processes.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,40 +106,14 @@ jobs:
106106
os: ${{ matrix.os }}
107107
directory: ${{ matrix.directory }}
108108

109-
# Calls the Pull Request Commenting workflow to leave a comment detailing how to test the PR within WordPress Playground.
110-
playground-comment:
111-
name: Leave WordPress Playground details
112-
runs-on: ubuntu-latest
113-
permissions:
114-
actions: write
115-
continue-on-error: true
116-
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos ]
117-
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request' }}
118-
119-
steps:
120-
- name: Dispatch workflow run
121-
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
122-
with:
123-
retries: 2
124-
retry-exempt-status-codes: 418
125-
script: |
126-
github.rest.actions.createWorkflowDispatch({
127-
owner: context.repo.owner,
128-
repo: context.repo.repo,
129-
workflow_id: 'pull-request-comments.yml',
130-
ref: 'trunk',
131-
inputs: {
132-
pr_number: '${{ github.event.number }}'
133-
}
134-
});
135109

136110
slack-notifications:
137111
name: Slack Notifications
138112
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
139113
permissions:
140114
actions: read
141115
contents: read
142-
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos, playground-comment ]
116+
needs: [ test-core-build-process, test-core-build-process-macos, test-gutenberg-build-process, test-gutenberg-build-process-macos ]
143117
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
144118
with:
145119
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
@@ -154,7 +128,7 @@ jobs:
154128
runs-on: ubuntu-latest
155129
permissions:
156130
actions: write
157-
needs: [ playground-comment ]
131+
needs: [ slack-notifications ]
158132
if: |
159133
always() &&
160134
github.repository == 'WordPress/wordpress-develop' &&

0 commit comments

Comments
 (0)