@@ -20,6 +20,12 @@ template:
20
20
name: <MY-COURSE-REPO>
21
21
` ;
22
22
23
+ /**
24
+ * File in `responses/` that is used as the content for comments that are posted
25
+ * when a user finishes the setup phase.
26
+ *
27
+ */
28
+ const INTRO_OK_MESSAGE = 'setup-ok.md' ;
23
29
/**
24
30
* File in `responses/` that is used as the content for comments that are posted
25
31
* when a user finishes a step.
@@ -46,6 +52,24 @@ const FAIL_MESSAGE = 'fail.md';
46
52
*/
47
53
const END_MESSAGE = 'end.md' ;
48
54
55
+ /**
56
+ * Setup steps of this course.
57
+ * Each of this step consists in a `.md` file that introduce the
58
+ * course, describe the setup ... before the actual query writing begins
59
+ */
60
+ const INTRO_ISSUES = [
61
+ {
62
+ title : 'Welcome!' ,
63
+ instructionsFile : 'step1-welcome.md' ,
64
+ activitiesFiles : [ ]
65
+ } ,
66
+ {
67
+ title : 'Set up your IDE' ,
68
+ instructionsFile : 'step2-setup.md' ,
69
+ activitiesFiles : [ '2-1.md' ]
70
+ }
71
+ ]
72
+
49
73
/**
50
74
* Each of the steps of this course, each step must have:
51
75
*
@@ -100,7 +124,7 @@ console.log(META.trim());
100
124
* @param step {{title: string;}}
101
125
* @param i {number}
102
126
*/
103
- const issueTitle = ( step , i ) => `Step ${ i + 1 } - ${ step . title } ` ;
127
+ const issueTitle = ( step , i ) => `Step ${ i + 1 + INTRO_ISSUES . length } - ${ step . title } ` ;
104
128
105
129
/**
106
130
* @param str {string}
@@ -117,20 +141,53 @@ const escapeDoubleQuoteYamlString = (str) =>
117
141
118
142
console . log ( `
119
143
before:
144
+ # Create Issues for introduction` ) ;
145
+
146
+ INTRO_ISSUES . map ( ( issue , i ) => {
147
+ console . log ( `
120
148
- type: createIssue
121
- title: '${ issueTitle ( STEPS [ 0 ] , 0 ) } '
122
- body: ${ STEPS [ 0 ] . instructionsFile } ` ) ;
123
- if ( STEPS [ 0 ] . activitiesFiles . length > 0 ) {
124
- console . log ( ` comments:` ) ;
125
- STEPS [ 0 ] . activitiesFiles . map ( activityFile => {
126
- console . log ( ` - ${ activityFile } ` ) ;
127
- } )
128
- }
129
- console . log ( ` action_id: step_1
149
+ title: ${ issue . title }
150
+ body: ${ issue . instructionsFile }
151
+ action_id: intro_${ i } ` ) ;
152
+ if ( issue . activitiesFiles . length > 0 ) {
153
+ console . log ( ` comments:` ) ;
154
+ issue . activitiesFiles . map ( activityFile => {
155
+ console . log ( ` - ${ activityFile } ` ) ;
156
+ } )
157
+ }
158
+ console . log ( `
159
+ - type: assignRegistrant
160
+ issue: '%actions.intro_${ i } .data.number%'` )
161
+ } )
162
+ console . log ( `
163
+ - type: createIssue
164
+ title: "${ escapeDoubleQuoteYamlString ( issueTitle ( STEPS [ 0 ] , 0 ) ) } "
165
+ body: ${ STEPS [ 0 ] . instructionsFile }
166
+ action_id: step_0` ) ;
167
+ if ( STEPS [ 0 ] . activitiesFiles . length > 0 ) {
168
+ console . log ( ` comments:` ) ;
169
+ STEPS [ 0 ] . activitiesFiles . map ( activityFile => {
170
+ console . log ( ` - ${ activityFile } ` ) ;
171
+ } )
172
+ }
173
+ console . log ( `
130
174
- type: assignRegistrant
131
- issue: '%actions.step_1 .data.number%'
175
+ issue: '%actions.step_0 .data.number%'` )
132
176
133
- steps:` ) ;
177
+ console . log ( `
178
+ steps:
179
+ - title: "Welcome to the course"
180
+ description: "Know where to find documentation and help, install CodeQL, setup your IDE."
181
+ event: issues.closed
182
+ link: '{{ repoUrl }}/issues/1'
183
+ actions:
184
+ - type: gate
185
+ left: '%payload.issue.title%'
186
+ operator: search
187
+ right: "${ escapeDoubleQuoteYamlString ( INTRO_ISSUES [ INTRO_ISSUES . length - 1 ] . title ) } "
188
+ - type: respond
189
+ issue: "${ escapeDoubleQuoteYamlString ( INTRO_ISSUES [ INTRO_ISSUES . length - 1 ] . title ) } "
190
+ with: ${ INTRO_OK_MESSAGE } ` ) ;
134
191
135
192
STEPS . map ( ( step , i ) => {
136
193
// The markdown string to look for in the comment from github-actions[bot]
@@ -140,7 +197,7 @@ STEPS.map((step, i) => {
140
197
- title: "${ escapeDoubleQuoteYamlString ( step . title ) } "
141
198
description: "${ escapeDoubleQuoteYamlString ( step . description ) } "
142
199
event: commit_comment.created
143
- link: '{{ repoUrl }}/issues${ i === 0 ? '/1' : '' } '
200
+ link: '{{ repoUrl }}/issues/ '
144
201
actions:
145
202
# Ensure comment is posted by github-actions
146
203
- type: gate
@@ -166,7 +223,7 @@ STEPS.map((step, i) => {
166
223
data:
167
224
commit: '%payload.comment.commit_id%'
168
225
commentUrl: '%payload.comment.html_url%'
169
-
226
+
170
227
# Answer is correct!!` ) ;
171
228
172
229
/* The following is disabled for now as Learning Lab is using ^15.18.3 of
@@ -216,11 +273,9 @@ STEPS.map((step, i) => {
216
273
# Create Issue for next task
217
274
- type: createIssue
218
275
title: "${ escapeDoubleQuoteYamlString ( issueTitle ( next , i + 1 ) ) } "
219
- body: ${ next . instructionsFile } ` ) ;
220
- if ( next . activitiesFiles . length > 0 ) {
221
- console . log ( ` comments:` ) ;
222
- }
223
- next . activitiesFiles . map ( file => {
276
+ body: ${ next . instructionsFile }
277
+ comments:` ) ;
278
+ next . activitiesFiles . map ( file => {
224
279
console . log ( ` - ${ file } ` )
225
280
} )
226
281
console . log ( ` action_id: next_issue
@@ -243,9 +298,9 @@ STEPS.map((step, i) => {
243
298
repo: '%payload.repository.name%'
244
299
sha: '%payload.comment.commit_id%'
245
300
body: |
246
- Congratulations, looks like the query you introduced for step ${ i + 1 } finds the correct results!
301
+ Congratulations, looks like the query you introduced for step ${ INTRO_ISSUES . length + i + 1 } finds the correct results!
247
302
248
- Take a look at the [instructions for the next step](%actions.next_issue.data.html_url%) to continue.
303
+ Merge this Pull Request (unless you're on master), and take a look at the [instructions for the next step](%actions.next_issue.data.html_url%) to continue.
249
304
250
305
# Close current issue
251
306
- type: closeIssue
0 commit comments