File tree Expand file tree Collapse file tree 5 files changed +46
-6
lines changed Expand file tree Collapse file tree 5 files changed +46
-6
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,8 @@ This reads from the `.github/ISSUE_TEMPLATE.md` file. This file should have fron
23
23
``` markdown
24
24
---
25
25
title: Someone just pushed
26
- assignees:
27
- - JasonEtco
28
- labels:
29
- - bug
26
+ assignees: JasonEtco, matchai
27
+ labels: bug, enhancement
30
28
---
31
29
Someone just pushed, oh no! Here's who did it: {{ payload.sender.login }}
32
30
```
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ const fm = require('front-matter')
3
3
const nunjucks = require ( 'nunjucks' )
4
4
const dateFilter = require ( 'nunjucks-date-filter' )
5
5
6
+ function listToArray ( list ) {
7
+ if ( ! list ) return [ ]
8
+ return Array . isArray ( list ) ? list : list . split ( ', ' )
9
+ }
10
+
6
11
Toolkit . run ( async tools => {
7
12
const template = tools . arguments . _ [ 0 ] || '.github/ISSUE_TEMPLATE.md'
8
13
const env = nunjucks . configure ( { autoescape : false } )
@@ -33,8 +38,8 @@ Toolkit.run(async tools => {
33
38
const issue = await tools . github . issues . create ( {
34
39
...tools . context . repo ,
35
40
...templated ,
36
- assignees : attributes . assignees || [ ] ,
37
- labels : attributes . labels || [ ] ,
41
+ assignees : listToArray ( attributes . assignees ) ,
42
+ labels : listToArray ( attributes . labels ) ,
38
43
milestone : attributes . milestone
39
44
} )
40
45
Original file line number Diff line number Diff line change @@ -34,6 +34,29 @@ Array [
34
34
]
35
35
` ;
36
36
37
+ exports [` create-an-issue creates a new issue with assignees and labels as comma-delimited strings 1` ] = `
38
+ Object {
39
+ " assignees" : Array [
40
+ " JasonEtco" ,
41
+ " matchai" ,
42
+ ],
43
+ " body" : " The action create-an-issue is the best action." ,
44
+ " labels" : Array [
45
+ " bug" ,
46
+ " enhancement" ,
47
+ ],
48
+ " title" : " DO EVERYTHING" ,
49
+ }
50
+ ` ;
51
+
52
+ exports [` create-an-issue creates a new issue with assignees and labels as comma-delimited strings 2` ] = `
53
+ Array [
54
+ Array [
55
+ "Created issue DO EVERYTHING#1: www",
56
+ ],
57
+ ]
58
+ ` ;
59
+
37
60
exports [` create-an-issue creates a new issue with assignees, labels and a milestone 1` ] = `
38
61
Object {
39
62
" assignees" : Array [
Original file line number Diff line number Diff line change
1
+ ---
2
+ title : DO EVERYTHING
3
+ assignees : JasonEtco, matchai
4
+ labels : bug, enhancement
5
+ ---
6
+ The action {{ action }} is the best action.
Original file line number Diff line number Diff line change @@ -62,4 +62,12 @@ describe('create-an-issue', () => {
62
62
expect ( tools . log . success ) . toHaveBeenCalled ( )
63
63
expect ( tools . log . success . mock . calls ) . toMatchSnapshot ( )
64
64
} )
65
+
66
+ it ( 'creates a new issue with assignees and labels as comma-delimited strings' , async ( ) => {
67
+ tools . arguments . _ [ 0 ] = '.github/split-strings.md'
68
+ await actionFn ( tools )
69
+ expect ( params ) . toMatchSnapshot ( )
70
+ expect ( tools . log . success ) . toHaveBeenCalled ( )
71
+ expect ( tools . log . success . mock . calls ) . toMatchSnapshot ( )
72
+ } )
65
73
} )
You can’t perform that action at this time.
0 commit comments