From b5cd6c5ef606321c26e4b11a8010966f13985548 Mon Sep 17 00:00:00 2001 From: matttrach Date: Tue, 19 Aug 2025 22:08:03 -0500 Subject: [PATCH] fix: remove try Signed-off-by: matttrach --- .github/pull_request_template.md | 3 +- .github/workflows/backport-prs.yml | 66 ++++++++++++++---------------- .github/workflows/backport.yml | 1 + .github/workflows/main-issue.yml | 7 ++-- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 23c2361..7d71e42 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,12 +1,13 @@ ## Related Issue -If this PR will target main, please complete the below sentence. +If this PR will target main, please correct the below sentence. Addresses #1234 (main issue) ## Releases If this PR should be released, please add labels for each release branch it targets. +Use the 'release/v0' tags, not the 'version/v0' tags. ## Description diff --git a/.github/workflows/backport-prs.yml b/.github/workflows/backport-prs.yml index a0b2616..5bcb999 100644 --- a/.github/workflows/backport-prs.yml +++ b/.github/workflows/backport-prs.yml @@ -41,7 +41,7 @@ jobs: return; } core.info(`Found associated PR: #${pr.number}`); - + core.info(`Searching for 'internal/main' issue linked to PR #${pr.number}`); const searchResults = await github.rest.search.issuesAndPullRequests({ q: `is:issue label:"internal/main" repo:${owner}/${repo} in:body #${pr.number}` @@ -53,7 +53,7 @@ jobs: } const mainIssue = searchResults.data.items[0]; core.info(`Found main issue: #${mainIssue.number}`); - + core.info(`Fetching sub-issues for main issue #${mainIssue.number}`); const { data: subIssues } = await github.rest.issues.listSubIssues({ owner, @@ -66,41 +66,35 @@ jobs: return; } core.info(`Found ${subIssues.length} sub-issues.`); - - for (const subIssue of subIssues) { - try { - const subIssueNumber = subIssue.number; - - // Find the release label directly on the sub-issue object - const releaseLabel = subIssue.labels.find(label => label.name.startsWith('release/v')); - if (!releaseLabel) { - core.warning(`Sub-issue #${subIssueNumber} has no 'release/v...' label. Skipping.`); - continue; - } - const targetBranch = releaseLabel.name - core.info(`Processing sub-issue #${subIssueNumber} for target branch: ${targetBranch}`); - - const newBranchName = `backport-${pr.number}-${targetBranch.replace(/\//g, '-')}`; - execSync(`git config user.name "github-actions[bot]"`); - execSync(`git config user.email "github-actions[bot]@users.noreply.github.com"`); - execSync(`git fetch origin ${targetBranch}`); - execSync(`git checkout -b ${newBranchName} origin/${targetBranch}`); - core.info(`Cherry-picking commit ${mergeCommitSha}...`); - execSync(`git cherry-pick -x ${mergeCommitSha}`); + for (const subIssue of subIssues) { + const subIssueNumber = subIssue.number; + + // Find the release label directly on the sub-issue object + const releaseLabel = subIssue.labels.find(label => label.name.startsWith('release/v')); + if (!releaseLabel) { + core.warning(`Sub-issue #${subIssueNumber} has no 'release/v...' label. Skipping.`); + continue; + } + const targetBranch = releaseLabel.name + core.info(`Processing sub-issue #${subIssueNumber} for target branch: ${targetBranch}`); - core.info(`Pushing new branch ${newBranchName}...`); - execSync(`git push origin ${newBranchName}`); - - core.info(`Creating pull request for branch ${newBranchName} targeting ${targetBranch}...`); + const newBranchName = `backport-${pr.number}-${targetBranch.replace(/\//g, '-')}`; + execSync(`git config user.name "github-actions[bot]"`); + execSync(`git config user.email "github-actions[bot]@users.noreply.github.com"`); + execSync(`git fetch origin ${targetBranch}`); + execSync(`git checkout -b ${newBranchName} origin/${targetBranch}`); + execSync(`git cherry-pick -x ${mergeCommitSha}`); + execSync(`git push origin ${newBranchName}`); - const { data: newPr } = await github.rest.pulls.create({ - owner, - repo, - title: pr.title, - head: newBranchName, - base: targetBranch, - body: "This pull request cherry-picks the changes from #" + pr.number + " into " + targetBranch, - }); - } + core.info(`Creating pull request for branch ${newBranchName} targeting ${targetBranch}...`); + const { data: newPr } = await github.rest.pulls.create({ + owner, + repo, + title: pr.title, + head: newBranchName, + base: targetBranch, + body: "This pull request cherry-picks the changes from #" + pr.number + " into " + targetBranch, + assignees: ['terraform-maintainers'] + }); } diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 270cc0a..0c51f8f 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -26,6 +26,7 @@ jobs: title: "Backport #" + parentIssueNumber + " to release/v0", body: "Backport #" + parentIssueNumber + " to release/v0" labels: ['release/v0'] + assignees: ['terraform-maintainers'] }); const subIssueId = newIssue.data.id; diff --git a/.github/workflows/main-issue.yml b/.github/workflows/main-issue.yml index c760c03..0e60130 100644 --- a/.github/workflows/main-issue.yml +++ b/.github/workflows/main-issue.yml @@ -18,7 +18,8 @@ jobs: const repo = context.repo.repo; const owner = context.repo.owner; const pr = context.payload.pull_request; - const reviewers = pr.requested_reviewers.map(reviewer => reviewer.login) + const releaseLabel = pr.head.labels.find(label => label.name.startsWith('release/v')); + const versionLabel = releaseLabel.name.replace('release/', 'version/'); // Create the main issue const newIssue = await github.rest.issues.create({ @@ -29,6 +30,6 @@ jobs: "Please add labels indicating the release versions eg. 'version/v0' \n\n" + "Please add comments for user issues which this issue addresses. \n\n" + "Description copied from PR: \n" + pr.body, - labels: ['internal/main'], - assignees: reviewers + labels: ['internal/main', versionLabel], + assignees: ['terraform-maintainers'] });