1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC. All Rights Reserved.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ * =============================================================================
16
+ */
17
+
18
+ /** Automatically assign issues and PRs to users in the `assigneesList`
19
+ * on a rotating basis.
20
+
21
+ @param {!object }
22
+ GitHub objects can call GitHub APIs using their built-in library functions.
23
+ The context object contains issue and PR details.
24
+ */
25
+
26
+ module . exports = async ( { github, context } ) => {
27
+ let issueNumber ;
28
+ let assigneesList ;
29
+ // Is this an issue? If so, assign the issue number. Otherwise, assign the PR number.
30
+ if ( context . payload . issue ) {
31
+ //assignee List for issues.
32
+ assigneesList = [ "tilakrayal" ] ;
33
+ issueNumber = context . payload . issue . number ;
34
+ } else {
35
+ //assignee List for PRs.
36
+ assigneesList = [ 'tilakrayal' ] ;
37
+ issueNumber = context . payload . number ;
38
+ }
39
+ console . log ( "assignee list" , assigneesList ) ;
40
+ console . log ( "entered auto assignment for this issue: " , issueNumber ) ;
41
+ if ( ! assigneesList . length ) {
42
+ console . log ( "No assignees found for this repo." ) ;
43
+ return ;
44
+ }
45
+ let noOfAssignees = assigneesList . length ;
46
+ let selection = issueNumber % noOfAssignees ;
47
+ let assigneeForIssue = assigneesList [ selection ] ;
48
+
49
+ console . log (
50
+ "issue Number = " ,
51
+ issueNumber + " , assigning to: " ,
52
+ assigneeForIssue
53
+ ) ;
54
+ return github . rest . issues . addAssignees ( {
55
+ issue_number : context . issue . number ,
56
+ owner : context . repo . owner ,
57
+ repo : context . repo . repo ,
58
+ assignees : [ assigneeForIssue ] ,
59
+ } ) ;
60
+ } ;
0 commit comments