From dbe0907a7870fda40df77cb3a23dd5c4884c25f8 Mon Sep 17 00:00:00 2001 From: matttrach Date: Wed, 20 Aug 2025 12:18:41 -0500 Subject: [PATCH] fix: add team members individually to issue Signed-off-by: matttrach --- .github/workflows/backport-prs.yml | 4 +++- .github/workflows/backport.yml | 13 ++++++++++--- .github/workflows/main-issue.yml | 15 ++++++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/backport-prs.yml b/.github/workflows/backport-prs.yml index 25376cc..4f29843 100644 --- a/.github/workflows/backport-prs.yml +++ b/.github/workflows/backport-prs.yml @@ -33,7 +33,7 @@ jobs: const { data: associatedPrs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ owner, repo, - commit_sha: mergeCommitSha, + commit_sha: mergeCommitSha }); const pr = associatedPrs.find(p => p.base.ref === 'main' && p.merged_at); if (!pr) { @@ -46,10 +46,12 @@ jobs: core.info(`Searching for 'internal/main' issue linked to PR #${pr.number}`); const { data: searchResults } = await github.request('GET /search/issues', { q: `is:issue label:"internal/main" repo:${owner}/${repo} in:body #${pr.number}`, + advanced_search: true, headers: { 'X-GitHub-Api-Version': '2022-11-28' } }); + core.info(`Search results: ${searchResults}`) if (searchResults.data.total_count === 0) { core.info(`No 'internal/main' issue found for PR #${pr.number}. Exiting.`); return; diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 0c51f8f..9bf76a9 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -19,14 +19,21 @@ jobs: const repo = context.repo.repo; const owner = context.repo.owner; + // Get terraform-maintainers team + const { data: teamMembers } = await github.rest.teams.listMembersInOrg({ + org: "rancher", + team_slug: "terraform-maintainers" + }); + const newAssignees = teamMembers.map(member => member.login); + // Create the sub-issue const newIssue = await github.rest.issues.create({ owner: owner, repo: repo, title: "Backport #" + parentIssueNumber + " to release/v0", - body: "Backport #" + parentIssueNumber + " to release/v0" - labels: ['release/v0'] - assignees: ['terraform-maintainers'] + body: "Backport #" + parentIssueNumber + " to release/v0", + labels: ['release/v0'], + assignees: newAssignees // assign terraform-maintainers to sub-issue }); const subIssueId = newIssue.data.id; diff --git a/.github/workflows/main-issue.yml b/.github/workflows/main-issue.yml index baabde5..12c0d0a 100644 --- a/.github/workflows/main-issue.yml +++ b/.github/workflows/main-issue.yml @@ -18,13 +18,22 @@ jobs: const repo = context.repo.repo; const owner = context.repo.owner; const pr = context.payload.pull_request; - const newLabels = ['internal/main'] + const newLabels = ['internal/main']; const releaseLabel = pr.labels.find(label => label.name.startsWith('release/v')); if (releaseLabel) { const versionLabel = releaseLabel.name.replace('release/', 'version/'); - newLabels.push(versionLabel) + newLabels.push(versionLabel); } + // Get terraform-maintainers team + const { data: teamMembers } = await github.rest.teams.listMembersInOrg({ + org: "rancher", + team_slug: "terraform-maintainers" + }); + const newAssignees = teamMembers.map(member => member.login); + // Create the main issue + // https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#create-an-issue + // Note: issues can't have teams assigned to them const newIssue = await github.rest.issues.create({ owner: owner, repo: repo, @@ -34,5 +43,5 @@ jobs: "Please add comments for user issues which this issue addresses. \n\n" + "Description copied from PR: \n" + pr.body, labels: newLabels, - assignees: ['terraform-maintainers'] + assignees: newAssignees // assign terraform-maintainers to issue });