-
-
Notifications
You must be signed in to change notification settings - Fork 1
59 lines (50 loc) · 2.88 KB
/
restrict-issue-creation.yml
File metadata and controls
59 lines (50 loc) · 2.88 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
name: Restrict issue creation to organization members
on:
issues:
types: [opened]
jobs:
check-membership:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check if issue creator is org member
uses: actions/github-script@v7
with:
script: |
const issueCreator = context.payload.issue.user.login;
const org = context.repo.owner;
console.log(`Checking if ${issueCreator} is a member of ${org}`);
try {
// Check if user is an organization member
await github.rest.orgs.checkMembershipForUser({
org: org,
username: issueCreator
});
console.log(`${issueCreator} is an organization member - issue will remain open`);
} catch (error) {
// User is not an org member
console.log(`${issueCreator} is not an organization member - closing issue`);
// Add a comment explaining why the issue is being closed
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `Hi @${issueCreator},\n\nThank you for your interest in the Home Assistant roadmap!\n\nThis repository is restricted to Open Home Foundation staff and authorized contributors only. Community members cannot directly create roadmap opportunities.\n\n**How to influence the roadmap:**\n1. 🚀 Submit your ideas to the [Feature Requests](https://github.com/orgs/home-assistant/discussions)\n2. 🗳️ Vote and discuss on existing feature requests\n3. 👀 The product team regularly reviews popular requests and creates roadmap opportunities based on community needs\n\nYour input is valuable and helps shape Home Assistant's future! Please share your ideas in the Feature Requests where they can be properly discussed and evaluated by the community and product team.\n\nIf you believe you should have access to create roadmap opportunities, please contact the Open Home Foundation team.\n\n*This issue will now be automatically closed.*`
});
// Close the issue
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed',
state_reason: 'not_planned'
});
// Add labels to indicate why it was closed
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['non-member', 'auto-closed']
});
}