Label PRs merged after Feature Freeze (#60250)

This commit is contained in:
Jorge A. Torres 2025-08-14 20:17:06 +01:00 committed by GitHub
parent 6c7fad08d5
commit f724d7faf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 83 additions and 17 deletions

View file

@ -57,6 +57,20 @@ jobs:
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
if: ${{ github.event.pull_request.merged && startsWith( github.event.pull_request.base.ref, 'release/' ) && ! contains( github.event.pull_request.labels.*.name, 'Release' ) }}
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr edit ${{ github.event.pull_request.number }} \
--add-label "metric: feature freeze exception" \
--repo ${{ github.repository }}
process-pull-request-after-close:
name: "Process a pull request after it's been closed"
runs-on: ubuntu-latest

View file

@ -170,7 +170,8 @@ jobs:
--title 'Bump WooCommerce version to ${{ steps.compute-new-version.outputs.nextVersion }}' \
--body 'This PR updates the versions in ${{ inputs.branch }} to ${{ steps.compute-new-version.outputs.nextVersion }}.' \
--base ${{ inputs.branch }} \
--head ${branch_name}
--head ${branch_name} \
--label Release
- name: Ensure milestone for dev version exists
if: ${{ inputs.bump-type == 'dev' }}

View file

@ -87,7 +87,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: trunk
- name: Check the necessary branch exists
id: check-branch
@ -123,7 +123,8 @@ jobs:
VERSION: ${{ steps.validate-version.outputs.version }}
SELECTED_BRANCH: ${{ steps.check-branch.outputs.selected_branch }}
run: |
git checkout $SELECTED_BRANCH
git fetch origin ${SELECTED_BRANCH}
git checkout ${SELECTED_BRANCH}
current_version=$( cat plugins/woocommerce/woocommerce.php | grep -oP '(?<=Version: )(.+)' | head -n1 )
echo "Current version from woocommerce.php: '$current_version'"
@ -136,6 +137,9 @@ jobs:
echo "current_version=$current_version" >> $GITHUB_OUTPUT
# Go back to trunk.
git checkout trunk
- name: Setup PNPM
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

View file

@ -15,7 +15,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
cfes=$( gh pr list --search "is:pr milestone:${{ inputs.milestone }} is:closed label:\"metric: code freeze exception\"" --json url | jq --compact-output '.[]' | jq --raw-output '( "- " + .url )' )
cfes=$( gh pr list --search "is:pr milestone:${{ inputs.milestone }} is:closed label:\"metric: feature freeze exception\"" --json url | jq --compact-output '.[]' | jq --raw-output '( "- " + .url )' )
issue=$( gh issue create --title "[Release] trend analysis for ${{ inputs.milestone }} milestone (CFEs)" --assignee "${{ github.actor }}" --body "Generated automatically via release-trends-analysis.yml." | grep '/issues/' | sed -E 's/[^0-9]*//' )
gh issue comment ${issue} --body "
@ -63,7 +63,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
cfes=$( gh pr list --search "is:pr milestone:${{ inputs.milestone }} is:closed label:\"metric: code freeze exception\"" --json url | jq --compact-output '.[]' | jq --raw-output '( "- " + .url )' )
cfes=$( gh pr list --search "is:pr milestone:${{ inputs.milestone }} is:closed label:\"metric: feature freeze exception\"" --json url | jq --compact-output '.[]' | jq --raw-output '( "- " + .url )' )
prrs=$( gh issue list --search "is:issue milestone:${{ inputs.milestone }} state:closed label:\"point release request\"" --json url | jq --compact-output '.[]' | jq --raw-output '( "- " + .url )' )
issue=$( gh issue create --title "[Release] quality trend analysis for ${{ inputs.milestone }} milestone (CFEs and PRRs)" --assignee "${{ github.actor }}" --body "Generated automatically via release-trends-analysis.yml." | grep '/issues/' | sed -E 's/[^0-9]*//' )

View file

@ -12,7 +12,10 @@ import { readFileSync } from 'fs';
*/
import { Logger } from '../../../../core/logger';
import { checkoutRemoteBranch } from '../../../../core/git';
import { createPullRequest } from '../../../../core/github/repo';
import {
addLabelsToIssue,
createPullRequest,
} from '../../../../core/github/repo';
import { Options } from '../types';
import { getToday } from '../../get-version/lib';
@ -179,6 +182,17 @@ export const updateReleaseBranchChangelogs = async (
base: releaseBranch,
} );
Logger.notice( `Pull request created: ${ pullRequest.html_url }` );
try {
await addLabelsToIssue( options, pullRequest.number, [
'Release',
] );
} catch {
Logger.warn(
`Could not add label "Release" to PR ${ pullRequest.number }`
);
}
return {
deletionCommitHash: deletionCommitHash.trim(),
prNumber: pullRequest.number,
@ -197,13 +211,14 @@ export const updateReleaseBranchChangelogs = async (
* @param {Object} releaseBranchChanges update data from updateReleaseBranchChangelogs
* @param {Object} releaseBranchChanges.deletionCommitHash commit from the changelog deletions in updateReleaseBranchChangelogs
* @param {Object} releaseBranchChanges.prNumber pr number created in updateReleaseBranchChangelogs
* @return {number} Update PR number.
*/
export const updateBranchChangelog = async (
options: Options,
tmpRepoPath: string,
releaseBranch: string,
releaseBranchChanges: { deletionCommitHash: string; prNumber: number }
): Promise< void > => {
): Promise< number > => {
const { owner, name, version } = options;
const { deletionCommitHash, prNumber } = releaseBranchChanges;
Logger.notice( `Deleting changelogs from trunk ${ tmpRepoPath }` );
@ -251,6 +266,18 @@ export const updateBranchChangelog = async (
base: releaseBranch,
} );
Logger.notice( `Pull request created: ${ pullRequest.html_url }` );
try {
await addLabelsToIssue( options, pullRequest.number, [
'Release',
] );
} catch {
Logger.warn(
`Could not add label "Release" to PR ${ pullRequest.number }`
);
}
return pullRequest.number;
} catch ( e ) {
if ( e.message.includes( `No commits between ${ releaseBranch }` ) ) {
Logger.notice(
@ -281,7 +308,7 @@ export const updateTrunkChangelog = async (
options: Options,
tmpRepoPath: string,
releaseBranchChanges: { deletionCommitHash: string; prNumber: number }
): Promise< void > => {
): Promise< number > => {
return await updateBranchChangelog(
options,
tmpRepoPath,

View file

@ -229,6 +229,26 @@ export const deleteGithubBranch = async (
);
};
export const addLabelsToIssue = async (
options: {
owner?: string;
name?: string;
},
issueNumber: number,
labels: string[]
): Promise< void > => {
const { owner, name } = options;
await octokitWithAuth().request(
'POST /repos/{owner}/{repo}/issues/{issue_number}/labels',
{
owner,
repo: name,
issue_number: issueNumber,
labels,
}
);
};
/**
* Create a pull request from branches on Github.
*