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
2323``` markdown
2424---
2525title: Someone just pushed
26- assignees:
27- - JasonEtco
28- labels:
29- - bug
26+ assignees: JasonEtco, matchai
27+ labels: bug, enhancement
3028---
3129Someone just pushed, oh no! Here's who did it: {{ payload.sender.login }}
3230```
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ const fm = require('front-matter')
33const nunjucks = require ( 'nunjucks' )
44const dateFilter = require ( 'nunjucks-date-filter' )
55
6+ function listToArray ( list ) {
7+ if ( ! list ) return [ ]
8+ return Array . isArray ( list ) ? list : list . split ( ', ' )
9+ }
10+
611Toolkit . run ( async tools => {
712 const template = tools . arguments . _ [ 0 ] || '.github/ISSUE_TEMPLATE.md'
813 const env = nunjucks . configure ( { autoescape : false } )
@@ -33,8 +38,8 @@ Toolkit.run(async tools => {
3338 const issue = await tools . github . issues . create ( {
3439 ...tools . context . repo ,
3540 ...templated ,
36- assignees : attributes . assignees || [ ] ,
37- labels : attributes . labels || [ ] ,
41+ assignees : listToArray ( attributes . assignees ) ,
42+ labels : listToArray ( attributes . labels ) ,
3843 milestone : attributes . milestone
3944 } )
4045
Original file line number Diff line number Diff line change @@ -34,6 +34,29 @@ Array [
3434]
3535` ;
3636
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+
3760exports [` create-an-issue creates a new issue with assignees, labels and a milestone 1` ] = `
3861Object {
3962 " 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', () => {
6262 expect ( tools . log . success ) . toHaveBeenCalled ( )
6363 expect ( tools . log . success . mock . calls ) . toMatchSnapshot ( )
6464 } )
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+ } )
6573} )
You can’t perform that action at this time.
0 commit comments