-
Notifications
You must be signed in to change notification settings - Fork 199
69 lines (60 loc) · 2.34 KB
/
status-notice.yml
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
name: 'Maintenance Status Notice'
on:
issues:
types: [opened]
pull_request:
types: [opened]
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
add-notice:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/github-script@v6
with:
script: |
const tagline = '⚠️ **Important Notice:** CRXJS is seeking new maintainers';
const message = `${tagline}.
- New issues and PRs may not receive immediate attention
- A new maintenance team must establish itself by March 31, 2025 or this repository will be archived on June 1, 2025
- [Learn more about the transition](https://github.com/crxjs/chrome-extension-tools/discussions/974)
---
*This is an automated message. Please do not reply to this comment.*`;
async function hasExistingNotice(params) {
const comments = await github.rest.issues.listComments(params);
const botLogin = 'github-actions[bot]';
return comments.data.some(comment =>
comment.user.login === botLogin && comment.body.includes(tagline)
);
}
try {
const owner = 'crxjs';
const repo = 'chrome-extension-tools';
let issueNumber;
// Determine context and get issue/PR number
if (context.eventName === 'issues' || context.eventName === 'issue_comment') {
issueNumber = context.issue.number;
} else {
issueNumber = context.payload.pull_request.number;
}
const params = {
owner,
repo,
issue_number: issueNumber,
};
// Only post if no existing notice found
if (!await hasExistingNotice(params)) {
await github.rest.issues.createComment({ ...params, body: message });
console.log('Maintenance notice posted successfully.');
} else {
console.log('Maintenance notice already exists. Skipping comment.');
}
} catch (error) {
console.error(error);
throw error; // Re-throw to ensure GitHub Action shows as failed
}