-
Notifications
You must be signed in to change notification settings - Fork 120
91 lines (77 loc) · 3.98 KB
/
pr-migration-warn.yml
File metadata and controls
91 lines (77 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Warn about intel/llvm migration
on:
schedule:
# Runs at 1:00 and 13:00 UTC daily
- cron: '0 1,13 * * *'
workflow_dispatch:
permissions:
contents: read
jobs:
label-and-comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Label and comment on open PRs
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const label = "auto-close";
// Fetch all open PRs
const open_pulls = await github.paginate(
github.rest.pulls.list,
{ owner, repo, state: "open" }
);
for (const pr of open_pulls) {
const pr_number = pr.number;
// Get current labels on the PR
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner,
repo,
issue_number: pr_number
});
// Get issue events
const { data: events } = await github.rest.issues.listEvents({
owner,
repo,
issue_number: pr_number
});
const hasLabelNow = labels.some(l => l.name === label);
const hadLabelBefore = events.some(e => e.event === "labeled" && e.label.name === label);
if (hasLabelNow || hadLabelBefore) {
console.log(`PR #${pr_number} already had or currently has the '${label}' label. Skipping.`);
continue;
}
// Add the label
await github.rest.issues.addLabels({
owner,
repo,
issue_number: pr_number,
labels: [label]
});
const commentBody =
"# Unified Runtime -> intel/llvm Repo Move Notice\n" +
"## Information\n" +
"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" +
"all future development will now be carried out there. This was done in https://github.com/intel/llvm/pull/17043.\n\n" +
"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" +
"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" +
"## PR Migration\n" +
"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" +
"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" +
"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" +
"If your PR should remain open and not be closed automatically, you can remove the `auto-close` label.\n\n" +
"---\n" +
"*This is an automated comment.*";
// Add a comment about the migration process
await github.rest.issues.createComment({
owner,
repo,
issue_number: pr_number,
body: commentBody
});
console.log(`Added label '${label}' and commented on PR #${pr_number}`);
}