Skip to content

Commit f9399a2

Browse files
sachinprasadhssampathweb
authored andcommitted
Create workflow for auto assignment of issues and for stale issues (#2313)
* Create auto-assignment.yaml * Create auto-assignment.js * Create stale-issue-pr.yaml * Rename auto-assignment.yaml to auto-assignment.yml * Rename stale-issue-pr.yaml to stale-issue-pr.yml
1 parent a235342 commit f9399a2

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed

.github/workflows/auto-assignment.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: auto-assignment
2+
on:
3+
issues:
4+
types:
5+
- opened
6+
7+
permissions:
8+
contents: read
9+
issues: write
10+
pull-requests: write
11+
12+
jobs:
13+
welcome:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const script = require('./\.github/workflows/scripts/auto-assignment.js')
21+
script({github, context})
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/** Automatically assign issues and PRs to users in the `assigneesList`
2+
* on a rotating basis.
3+
4+
@param {!object}
5+
GitHub objects can call GitHub APIs using their built-in library functions.
6+
The context object contains issue and PR details.
7+
*/
8+
9+
module.exports = async ({ github, context }) => {
10+
let issueNumber;
11+
let assigneesList;
12+
// Is this an issue? If so, assign the issue number. Otherwise, assign the PR number.
13+
if (context.payload.issue) {
14+
//assignee List for issues.
15+
assigneesList = ["SuryanarayanaY", "sachinprasadhs"];
16+
issueNumber = context.payload.issue.number;
17+
} else {
18+
//assignee List for PRs.
19+
assigneesList = [];
20+
issueNumber = context.payload.number;
21+
}
22+
console.log("assignee list", assigneesList);
23+
console.log("entered auto assignment for this issue: ", issueNumber);
24+
if (!assigneesList.length) {
25+
console.log("No assignees found for this repo.");
26+
return;
27+
}
28+
let noOfAssignees = assigneesList.length;
29+
let selection = issueNumber % noOfAssignees;
30+
let assigneeForIssue = assigneesList[selection];
31+
32+
console.log(
33+
"issue Number = ",
34+
issueNumber + " , assigning to: ",
35+
assigneeForIssue
36+
);
37+
return github.rest.issues.addAssignees({
38+
issue_number: context.issue.number,
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
assignees: [assigneeForIssue],
42+
});
43+
};

.github/workflows/stale-issue-pr.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Close inactive issues
2+
on:
3+
schedule:
4+
- cron: "30 1 * * *"
5+
jobs:
6+
close-issues:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
steps:
12+
- name: Awaiting response issues
13+
uses: actions/stale@v9
14+
with:
15+
days-before-issue-stale: 14
16+
days-before-issue-close: 14
17+
stale-issue-label: "stale"
18+
# reason for closed the issue default value is not_planned
19+
close-issue-reason: completed
20+
only-labels: "stat:awaiting response from contributor"
21+
stale-issue-message: >
22+
This issue is stale because it has been open for 14 days with no activity.
23+
It will be closed if no further activity occurs. Thank you.
24+
# List of labels to remove when issues/PRs unstale.
25+
labels-to-remove-when-unstale: "stat:awaiting response from contributor"
26+
close-issue-message: >
27+
This issue was closed because it has been inactive for 28 days.
28+
Please reopen if you'd like to work on this further.
29+
days-before-pr-stale: 14
30+
days-before-pr-close: 14
31+
stale-pr-message: "This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you."
32+
close-pr-message: "This PR was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further."
33+
repo-token: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Contribution issues
35+
uses: actions/stale@v9
36+
with:
37+
days-before-issue-stale: 180
38+
days-before-issue-close: 365
39+
stale-issue-label: "stale"
40+
# reason for closed the issue default value is not_planned
41+
close-issue-reason: not_planned
42+
any-of-labels: "stat:contributions welcome,good first issue"
43+
# List of labels to remove when issues/PRs unstale.
44+
labels-to-remove-when-unstale: "stat:contributions welcome,good first issue"
45+
stale-issue-message: >
46+
This issue is stale because it has been open for 180 days with no activity.
47+
It will be closed if no further activity occurs. Thank you.
48+
close-issue-message: >
49+
This issue was closed because it has been inactive for more than 1 year.
50+
repo-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)