|
| 1 | +name: Warn about intel/llvm migration |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 * * * *' # Runs hourly |
| 6 | + workflow_dispatch: # Allows manual triggering |
| 7 | + |
| 8 | +permissions: |
| 9 | + pull-requests: write |
| 10 | + issues: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + label-and-comment: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Label and comment on open PRs |
| 17 | + uses: actions/github-script@v6 |
| 18 | + with: |
| 19 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + script: | |
| 21 | + const { owner, repo } = context.repo; |
| 22 | + const label = "auto-close"; |
| 23 | +
|
| 24 | + // Fetch all open PRs |
| 25 | + const open_pulls = await github.paginate( |
| 26 | + github.rest.pulls.list, |
| 27 | + { owner, repo, state: "open" } |
| 28 | + ); |
| 29 | +
|
| 30 | + for (const pr of open_pulls) { |
| 31 | + const pr_number = pr.number; |
| 32 | +
|
| 33 | + // Get current labels on the PR |
| 34 | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ |
| 35 | + owner, |
| 36 | + repo, |
| 37 | + issue_number: pr_number |
| 38 | + }); |
| 39 | +
|
| 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.*"; |
| 64 | +
|
| 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 | + }); |
| 72 | +
|
| 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.`); |
| 76 | + } |
| 77 | + } |
0 commit comments