Skip to content

Commit e9852b0

Browse files
authored
Merge pull request #2739 from martygrant/martin/updatePRWarningScript
Update PR migration warning workflow to skip PRs where the label was manually removed
2 parents 0ec7036 + a95af59 commit e9852b0

File tree

1 file changed

+44
-34
lines changed

1 file changed

+44
-34
lines changed

.github/workflows/pr-migration-warn.yml

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,41 +37,51 @@ jobs:
3737
issue_number: pr_number
3838
});
3939
40-
// Check if label is already present
41-
if (!labels.some(labelObj => labelObj.name === label)) {
42-
// Add the label if not present
43-
await github.rest.issues.addLabels({
44-
owner,
45-
repo,
46-
issue_number: pr_number,
47-
labels: [label]
48-
});
49-
50-
const commentBody =
51-
"# Unified Runtime -> intel/llvm Repo Move Notice\n" +
52-
"## Information\n" +
53-
"The source code of Unified Runtime has been moved to [intel/llvm](https://github.com/intel/llvm) under the [unified-runtime](https://github.com/intel/llvm/tree/sycl/unified-runtime) top-level directory,\n" +
54-
"all future development will now be carried out there. This was done in https://github.com/intel/llvm/pull/17043.\n\n" +
55-
"The code will be mirrored to [oneapi-src/unified-runtime](https://github.com/oneapi-src/unified-runtime) and the specification will continue to be hosted at [oneapi-src.github.io/unified-runtime](https://oneapi-src.github.io/unified-runtime/).\n\n" +
56-
"The [contribution guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html) will be updated with new instructions for contributing to Unified Runtime.\n\n" +
57-
"## PR Migration\n" +
58-
"All open PRs including this one will be marked with the `auto-close` [label](https://github.com/oneapi-src/unified-runtime/labels/auto-close) and shall be **automatically closed after 30 days**.\n\n" +
59-
"Should you wish to continue with your PR **you will need to migrate it** to [intel/llvm](https://github.com/intel/llvm/tree/sycl/unified-runtime).\n" +
60-
"We have provided a [script to help automate this process](https://github.com/oneapi-src/unified-runtime/blob/main/scripts/move-pr-to-intel-llvm.py).\n\n" +
61-
"If your PR should remain open and not be closed automatically, you can remove the `auto-close` label.\n\n" +
62-
"---\n" +
63-
"*This is an automated comment.*";
40+
// Get issue events
41+
const { data: events } = await github.rest.issues.listEvents({
42+
owner,
43+
repo,
44+
issue_number: pr_number
45+
});
6446
65-
// Add a comment about the migration process
66-
await github.rest.issues.createComment({
67-
owner,
68-
repo,
69-
issue_number: pr_number,
70-
body: commentBody
71-
});
47+
const hasLabelNow = labels.some(l => l.name === label);
48+
const hadLabelBefore = events.some(e => e.event === "labeled" && e.label.name === label);
7249
73-
console.log(`Added label '${label}' and commented on PR #${pr_number}`);
74-
} else {
75-
console.log(`PR #${pr_number} already has the '${label}' label. Skipping.`);
50+
if (hasLabelNow || hadLabelBefore) {
51+
console.log(`PR #${pr_number} already had or currently has the '${label}' label. Skipping.`);
52+
continue;
7653
}
54+
55+
// Add the label
56+
await github.rest.issues.addLabels({
57+
owner,
58+
repo,
59+
issue_number: pr_number,
60+
labels: [label]
61+
});
62+
63+
const commentBody =
64+
"# Unified Runtime -> intel/llvm Repo Move Notice\n" +
65+
"## Information\n" +
66+
"The source code of Unified Runtime has been moved to [intel/llvm](https://github.com/intel/llvm) under the [unified-runtime](https://github.com/intel/llvm/tree/sycl/unified-runtime) top-level directory,\n" +
67+
"all future development will now be carried out there. This was done in https://github.com/intel/llvm/pull/17043.\n\n" +
68+
"The code will be mirrored to [oneapi-src/unified-runtime](https://github.com/oneapi-src/unified-runtime) and the specification will continue to be hosted at [oneapi-src.github.io/unified-runtime](https://oneapi-src.github.io/unified-runtime/).\n\n" +
69+
"The [contribution guide](https://oneapi-src.github.io/unified-runtime/core/CONTRIB.html) will be updated with new instructions for contributing to Unified Runtime.\n\n" +
70+
"## PR Migration\n" +
71+
"All open PRs including this one will be marked with the `auto-close` [label](https://github.com/oneapi-src/unified-runtime/labels/auto-close) and shall be **automatically closed after 30 days**.\n\n" +
72+
"Should you wish to continue with your PR **you will need to migrate it** to [intel/llvm](https://github.com/intel/llvm/tree/sycl/unified-runtime).\n" +
73+
"We have provided a [script to help automate this process](https://github.com/oneapi-src/unified-runtime/blob/main/scripts/move-pr-to-intel-llvm.py).\n\n" +
74+
"If your PR should remain open and not be closed automatically, you can remove the `auto-close` label.\n\n" +
75+
"---\n" +
76+
"*This is an automated comment.*";
77+
78+
// Add a comment about the migration process
79+
await github.rest.issues.createComment({
80+
owner,
81+
repo,
82+
issue_number: pr_number,
83+
body: commentBody
84+
});
85+
86+
console.log(`Added label '${label}' and commented on PR #${pr_number}`);
7787
}

0 commit comments

Comments
 (0)