Commit e5e6f3588b for woocommerce

commit e5e6f3588b168bfe871d7be43c2c3c706fdfc742
Author: Eric Binnion <ericbinnion@gmail.com>
Date:   Tue Nov 18 08:50:38 2025 -0500

    Automation: Require milestones on PRs (#61756)

    * Automation: Require milestones on PRs

    * Update header to be more correct after changes

    ---------

    Co-authored-by: Brandon Kraft <public@brandonkraft.com>

diff --git a/.github/workflows/pr-require-milestone.yml b/.github/workflows/pr-require-milestone.yml
new file mode 100644
index 0000000000..b33d615064
--- /dev/null
+++ b/.github/workflows/pr-require-milestone.yml
@@ -0,0 +1,41 @@
+name: 'Require milestone on pull requests'
+
+on:
+  pull_request:
+    types:
+      - opened
+      - reopened
+      - edited
+      - synchronize
+      - ready_for_review
+      - milestoned
+      - demilestoned
+    branches:
+        - trunk
+
+permissions:
+  pull-requests: read
+
+jobs:
+  ensure-milestone:
+    name: 'Ensure milestone is assigned'
+    if: github.event.pull_request.draft == false
+    runs-on: ubuntu-latest
+    steps:
+      - name: 'Validate milestone'
+        uses: actions/github-script@v7
+        with:
+          script: |
+            const prNumber = context.payload.pull_request.number;
+            const { data: issue } = await github.rest.issues.get({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                issue_number: prNumber,
+            });
+
+            if (!issue.milestone) {
+                core.setFailed('Assign a milestone before merging this pull request.');
+                return;
+            }
+
+            core.info(`Milestone "${issue.milestone.title}" is set.`);
\ No newline at end of file
diff --git a/.github/workflows/pull-request-post-merge-processing.yml b/.github/workflows/pull-request-post-merge-processing.yml
index c31c107353..8d2d32ee3e 100644
--- a/.github/workflows/pull-request-post-merge-processing.yml
+++ b/.github/workflows/pull-request-post-merge-processing.yml
@@ -19,14 +19,14 @@ jobs:
         steps:
             - name: 'Get the action scripts'
               run: |
-                  scripts="assign-milestone-to-merged-pr.php add-post-merge-comment.php post-request-shared.php"
+                  scripts="add-post-merge-comment.php post-request-shared.php"
                   for script in $scripts
                   do
                     curl \
                     --silent \
                     --fail \
                     --header 'Authorization: bearer ${{ secrets.GITHUB_TOKEN }}' \
-                    --header 'User-Agent: GitHub action to set the milestone for a pull request' \
+                    --header 'User-Agent: GitHub action for post-merge pull request processing' \
                     --header 'Accept: application/vnd.github.v3.raw' \
                     --output $script \
                     --location "$GITHUB_API_URL/repos/${{ github.repository }}/contents/.github/workflows/scripts/$script?ref=${{ github.event.pull_request.base.ref }}"
@@ -37,25 +37,6 @@ jobs:
               uses: shivammathur/setup-php@8e2ac35f639d3e794c1da1f28999385ab6fdf0fc
               with:
                   php-version: '7.4'
-            - name: Check if PR has milestone
-              id: check_milestone
-              uses: actions/github-script@v7
-              with:
-                script: |
-                  const pr_number = context.payload.pull_request.number;
-                   const { data: issue } = await github.rest.issues.get({
-                    owner: context.repo.owner,
-                    repo: context.repo.repo,
-                    issue_number: pr_number
-                  });
-                  core.setOutput('milestone_exists', !!issue.milestone);
-            - name: 'Run the script to assign a milestone'
-              if: github.event.pull_request.base.ref == 'trunk' &&
-                steps.check_milestone.outputs.milestone_exists == 'false'
-              run: php assign-milestone-to-merged-pr.php
-              env:
-                  PULL_REQUEST_ID: ${{ github.event.pull_request.node_id }}
-                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

     process-feature-freeze-exception:
         name: Log the merge of a Feature Freeze exception
diff --git a/.github/workflows/scripts/assign-milestone-to-merged-pr.php b/.github/workflows/scripts/assign-milestone-to-merged-pr.php
deleted file mode 100644
index ecf31ab7bd..0000000000
--- a/.github/workflows/scripts/assign-milestone-to-merged-pr.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Script to automatically assign a milestone to a pull request when it's merged.
- *
- * @package WooCommerce/GithubActions
- */
-
-// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions
-
-require_once __DIR__ . '/post-request-shared.php';
-
-$chosen_milestone = get_latest_milestone_from_api( true );
-
-echo 'Milestone that will be assigned: ' . $chosen_milestone['title'] . "\n";
-
-if ( getenv( 'DRY_RUN' ) ) {
-	echo "Dry run, skipping the actual milestone assignment\n";
-	return;
-}
-
-/*
- * Assign the milestone to the pull request.
- */
-
-echo 'Assigning the milestone to the pull request... ';
-
-$milestone_id = $chosen_milestone['id'];
-$mutation     = "
-  updatePullRequest(input: {pullRequestId: \"$pr_id\", milestoneId: \"$milestone_id\"}) {
-    clientMutationId
-  }
-";
-
-$result = do_graphql_api_request( $mutation, true );
-if ( is_array( $result ) ) {
-	if ( empty( $result['errors'] ) ) {
-		echo "Ok!\n";
-	} else {
-		echo "\n*** Errors found while assigning the milestone:\n";
-		echo var_dump( $result['errors'] );
-	}
-} else {
-	echo "\n*** Error found while assigning the milestone: file_get_contents returned the following:\n";
-	echo var_dump( $result );
-}
-
-// phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.AlternativeFunctions