Skip to content

Commit 8d06a68

Browse files
authored
fix: change from "main" to "tracking" (#1712) (#1728)
Signed-off-by: matttrach <matt.trachier@suse.com>
1 parent b3a177c commit 8d06a68

5 files changed

Lines changed: 31 additions & 32 deletions

File tree

.github/workflows/backport-pr-manual.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99

1010
env :
11-
TERRAFORM_MAINTAINERS: ${{ vars.TERRAFORM_MAINTAINERS }} # eg. '["matttrach"]'
11+
TERRAFORM_MAINTAINERS: ${{ vars.TERRAFORM_MAINTAINERS }} # eg. ["matttrach"]
1212

1313
jobs:
1414
create-cherry-pick-prs:

.github/workflows/scripts/backport-issues.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ async ({ github, context, core, process }) => {
77
const owner = context.repo.owner;
88
const assignees = JSON.parse(process.env.TERRAFORM_MAINTAINERS);
99
const extractedPrNumber = JSON.parse(process.env.PR);
10+
let response; // used to hold all github responses
1011

1112
// Retrieve the PR to get its data
12-
let response;
1313
try {
1414
response = await github.rest.issues.get({
1515
owner: owner,
@@ -19,15 +19,13 @@ async ({ github, context, core, process }) => {
1919
} catch (error) {
2020
core.setFailed(`Failed to retrieve PR #${extractedPrNumber}: ${error.message}`);
2121
}
22-
let pr = response.data;
23-
let prNumber = pr.number;
22+
const pr = response.data;
23+
const prNumber = pr.number;
2424

2525
// Note: can't get terraform-maintainers team, the default token can't access org level objects
2626
// Create the sub-issue
27-
let newIssue;
28-
let subIssueId;
2927
try {
30-
newIssue = await github.rest.issues.create({
28+
response = await github.rest.issues.create({
3129
owner: owner,
3230
repo: repo,
3331
title: `[Backport][${labelName}] ${parentIssueTitle}`,
@@ -42,7 +40,8 @@ async ({ github, context, core, process }) => {
4240
} catch (error) {
4341
core.setFailed(`Failed to create backport issue: ${error.message}`);
4442
}
45-
subIssueId = newIssue.data.id;
43+
const newIssue = response.data;
44+
const subIssueId = newIssue.id;
4645

4746
// Attach the sub-issue to the parent, use REST API because there isn't a github-script API yet.
4847
try {
@@ -56,6 +55,6 @@ async ({ github, context, core, process }) => {
5655
}
5756
});
5857
} catch (error) {
59-
core.setFailed(`Failed to link backport issue to main issue: ${error.message}`);
58+
core.setFailed(`Failed to link backport issue to tracking issue: ${error.message}`);
6059
}
6160
};

.github/workflows/scripts/backport-pr.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ export default async ({ github, core, process }) => {
44
const repo = "terraform-provider-rancher2";
55
const mergeCommitSha = process.env.MERGE_COMMIT_SHA;
66
const assignees = JSON.parse(process.env.TERRAFORM_MAINTAINERS);
7+
let response; // used to hold all github responses
78

89
// https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-pull-requests-associated-with-a-commit
9-
let response;
1010
try {
1111
response = await github.rest.repos.listPullRequestsAssociatedWithCommit({
1212
owner,
@@ -30,50 +30,50 @@ export default async ({ github, core, process }) => {
3030
core.info(`Found associated PR: #${pr.number}`);
3131

3232
// https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#search-issues-and-pull-requests
33-
core.info(`Searching for 'internal/main' issue linked to PR #${pr.number}`);
33+
core.info(`Searching for 'internal/tracking' issue linked to PR #${pr.number}`);
3434
try {
3535
response = await github.request('GET /search/issues', {
36-
q: `is:issue state:open label:"internal/main" repo:${owner}/${repo} in:body #${pr.number}`,
36+
q: `is:issue state:open label:"internal/tracking" repo:${owner}/${repo} in:body #${pr.number}`,
3737
advanced_search: true,
3838
headers: {
3939
'X-GitHub-Api-Version': '2022-11-28'
4040
}
4141
});
4242
} catch (error) {
43-
core.setFailed(`Failed to search for main issue for PR #${pr.number}: ${error.message}`);
43+
core.setFailed(`Failed to search for internal/tracking issue for PR #${pr.number}: ${error.message}`);
4444
}
4545
const searchResults = response.data;
4646
if (searchResults.total_count === 0) {
47-
core.info(`No 'internal/main' issue found for PR #${pr.number}. Exiting.`);
47+
core.info(`No 'internal/tracking' issue found for PR #${pr.number}. Exiting.`);
4848
return;
4949
}
50-
const mainIssue = searchResults.items[0];
51-
core.info(`Found main issue: #${mainIssue.number}`);
50+
const trackingIssue = searchResults.items[0];
51+
core.info(`Found tracking issue: #${trackingIssue.number}`);
5252

5353
// https://docs.github.com/en/rest/issues/sub-issues?apiVersion=2022-11-28#add-sub-issue
54-
core.info(`Fetching sub-issues for main issue #${mainIssue.number}`);
54+
core.info(`Fetching sub-issues for tracking issue #${trackingIssue.number}`);
5555
try {
5656
response = await github.request('GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues', {
5757
owner: owner,
5858
repo: repo,
59-
issue_number: mainIssue.number,
59+
issue_number: trackingIssue.number,
6060
headers: {
6161
'X-GitHub-Api-Version': '2022-11-28'
6262
}
6363
});
6464
} catch (error) {
65-
core.setFailed(`Failed to fetch sub-issues for main issue #${mainIssue.number}: ${error.message}`);
65+
core.setFailed(`Failed to fetch sub-issues for tracking issue #${trackingIssue.number}: ${error.message}`);
6666
}
67-
const subIssues = response.data.sub_issues;
67+
const subIssues = response.data;
6868
if (subIssues.length === 0) {
69-
core.info(`No sub-issues found for issue #${mainIssue.number}. Exiting.`);
69+
core.info(`No sub-issues found for issue #${trackingIssue.number}. Exiting.`);
7070
return;
7171
}
7272
core.info(`Found ${subIssues.length} sub-issues.`);
7373

7474
for (const subIssue of subIssues) {
75-
core.info(`Processing sub-issue #${subIssue.number}...`);
7675
const subIssueNumber = subIssue.number;
76+
core.info(`Processing sub-issue #${subIssueNumber}...`);
7777

7878
// Find the release label directly on the sub-issue object
7979
const releaseLabel = subIssue.labels.find(label => label.name.startsWith('release/v'));
@@ -105,7 +105,7 @@ export default async ({ github, core, process }) => {
105105
base: targetBranch,
106106
body: [
107107
`This pull request cherry-picks the changes from #${pr.number} into ${targetBranch}`,
108-
`Addresses #${subIssueNumber} for #${mainIssue.number}`,
108+
`Addresses #${subIssueNumber} for #${trackingIssue.number}`,
109109
`**WARNING!**: to avoid having to resolve merge conflicts this PR is generated with 'git cherry-pick -X theirs'.`,
110110
`Please make sure to carefully inspect this PR so that you don't accidentally revert anything!`,
111111
`Please add the proper milestone to this PR`,

.github/workflows/scripts/main-issue.js renamed to .github/workflows/scripts/tracking-issue.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ async ({ github, core, context, process }) => {
1919
owner: owner,
2020
repo: repo,
2121
title: pr.title,
22-
body: `This is the main issue tracking #${pr.number} \n\n` +
22+
body: `This is the tracking issue for #${pr.number} \n\n` +
2323
`Please add labels indicating the release versions eg. 'release/v13' \n\n` +
2424
`Please add comments for user issues which this issue addresses. \n\n` +
2525
`Description copied from PR: \n${pr.body}`,
2626
labels: newLabels,
2727
assignees: assignees
2828
});
2929
} catch (error) {
30-
core.setFailed(`Failed to create main issue: ${error.message}`);
30+
core.setFailed(`Failed to create tracking issue: ${error.message}`);
3131
}
3232
const newIssue = response.data;
3333
if (releaseLabel) {
3434
// if release label detected, then add appropriate sub-issues
35-
const parentIssue = newIssue.data;
35+
const parentIssue = newIssue;
3636
const parentIssueTitle = parentIssue.title;
3737
const parentIssueNumber = parentIssue.number;
3838
// Note: can't get terraform-maintainers team, the default token can't access org level objects
@@ -51,7 +51,7 @@ async ({ github, core, context, process }) => {
5151
core.setFailed(`Failed to create backport issue: ${error.message}`);
5252
}
5353
const newSubIssue = response.data;
54-
const subIssueId = newSubIssue.data.id;
54+
const subIssueId = newSubIssue.id;
5555
// Attach the sub-issue to the parent using API request
5656
try {
5757
await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues', {
@@ -64,7 +64,7 @@ async ({ github, core, context, process }) => {
6464
}
6565
});
6666
} catch (error) {
67-
core.setFailed(`Failed to link backport issue to main issue: ${error.message}`);
67+
core.setFailed(`Failed to link backport issue to tracking issue: ${error.message}`);
6868
}
6969
}
7070
};
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: MainIssue
2-
# This workflow generates a "main" issue when a PR is created targeting main.
1+
name: TrackingIssue
2+
# This workflow generates a "tracking" issue when a PR is created targeting main.
33
on:
44
pull_request_target:
55
branches: [main]
@@ -10,7 +10,7 @@ env :
1010

1111
jobs:
1212
generate-issue:
13-
name: 'Create Main Issue'
13+
name: 'Create Tracking Issue'
1414
runs-on: ubuntu-latest
1515
permissions:
1616
issues: write
@@ -29,7 +29,7 @@ jobs:
2929
const response = await github.rest.repos.getContent({
3030
owner: context.repo.owner,
3131
repo: context.repo.repo,
32-
path: ".github/workflows/scripts/main-issue.js",
32+
path: ".github/workflows/scripts/tracking-issue.js",
3333
ref: context.sha,
3434
});
3535
const scriptContent = Buffer.from(response.data.content, "base64").toString();

0 commit comments

Comments
 (0)