Skip to content
Open
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
10 changes: 9 additions & 1 deletion .github/workflows/build-plugin-zip.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
name: Build Plugin Zip

on:
workflow_call:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to maintain the ability to call the build ZIP action manually from the Actions page (e.g. someone wanting to create a specific build from a specific branch)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting the only event we had previously was workflow_call which allows other workflows to call this one but doesn't provide the UI for a user to call the workflow. For that, we need to add workflow_dispatch as an event. That can be done here if you want, just wanted to note that currently isn't how it's set up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, was more curiosity, fine to proceed without.

pull_request:
types: [ 'opened', 'synchronize', 'reopened' ]

# 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.
Expand Down
20 changes: 6 additions & 14 deletions .github/workflows/pull-request-comments.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Pull Request Comments

on:
pull_request:
pull_request_target:
types: [ 'opened', 'synchronize', 'reopened', 'edited' ]

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

# Disable permissions for all available scopes by default.
Expand All @@ -17,19 +17,10 @@ permissions: {}

jobs:

# Builds the plugin ZIP file.
build-plugin-zip:
name: Build plugin zip
uses: ./.github/workflows/build-plugin-zip.yml
permissions:
contents: read
pull-requests: read

# Leaves a comment on a pull request with a link to test the changes in a WordPress Playground instance.
playground-details:
name: Comment on a pull request with Playground details
runs-on: ubuntu-24.04
needs: build-plugin-zip
permissions:
pull-requests: write
contents: read
Expand Down Expand Up @@ -59,7 +50,7 @@ jobs:
let foundString = false;

// Check PR body.
if (pr.body.includes(searchString)) {
if (pr.body && pr.body.includes(searchString)) {
foundString = true;
}

Expand All @@ -75,6 +66,7 @@ jobs:
script: |
const prNumber = context.issue.number;
const blueprint = {
landingPage: '/wp-admin/',
preferredVersions: {
php: '7.4',
wp: 'latest',
Expand All @@ -89,7 +81,7 @@ jobs:
path: '/tmp/pr/pr.zip',
data: {
resource: 'url',
url: `/plugin-proxy.php?org=WordPress&repo=ai&workflow=Pull%20Request%20Comments&artifact=ai&pr=${prNumber}`,
url: `/plugin-proxy.php?org=WordPress&repo=ai&workflow=Build%20Plugin%20Zip&artifact=ai&pr=${prNumber}`,
caption: `Downloading AI Experiments PR ${prNumber}`,
},
},
Expand Down Expand Up @@ -123,7 +115,7 @@ jobs:
[Click here to test this pull request](${blueprintUrl}).`;

// Append the comment to the existing PR body.
const updatedBody = pr.body + '\n\n' + playgroundComment;
const updatedBody = `${pr.body ?? ''}\n\n${playgroundComment}`.trim();

// Update the PR body.
await github.rest.pulls.update({
Expand Down