@@ -29,6 +29,14 @@ template:
29
29
* * `{{commit}}` - Sha that was the head of the most recent PUSH
30
30
*/
31
31
const NEXT_MESSAGE = 'next.md' ;
32
+ /**
33
+ * File in `responses/` that is used as the content for comments that are posted
34
+ * when a user fails a step.
35
+ *
36
+ * Makes use of the placeholders:
37
+ * * `{{commit}}` - Sha that was the head of the most recent PUSH
38
+ */
39
+ const FAIL_MESSAGE = 'fail.md' ;
32
40
/**
33
41
* File in `responses/` that is used as the content for the comment that is
34
42
* posted when a user finishes the last step.
@@ -58,6 +66,7 @@ const END_MESSAGE = 'end.md';
58
66
* instructionsFile: string;
59
67
* title: string;
60
68
* description: string;
69
+ * activitiesFiles: string[];
61
70
* }>
62
71
*/
63
72
const STEPS = [
@@ -66,14 +75,16 @@ const STEPS = [
66
75
expectedResults : 3 ,
67
76
instructionsFile : 'step-1.md' ,
68
77
title : 'Your first query' ,
69
- description : 'Write your first query'
78
+ description : 'Write your first query' ,
79
+ activitiesFiles : [ ]
70
80
} ,
71
81
{
72
82
queryFile : 'step-2.ql' ,
73
83
expectedResults : 5 ,
74
84
instructionsFile : 'step-2.md' ,
75
85
title : 'Your second query' ,
76
- description : 'Write your second query'
86
+ description : 'Write your second query' ,
87
+ activitiesFiles : [ ]
77
88
}
78
89
] ;
79
90
@@ -108,13 +119,23 @@ console.log(`
108
119
before:
109
120
- type: createIssue
110
121
title: '${ issueTitle ( STEPS [ 0 ] , 0 ) } '
111
- body: ${ STEPS [ 0 ] . instructionsFile }
112
- steps:
113
- ` . trim ( ) ) ;
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
130
+ - type: assignRegistrant
131
+ issue: '%actions.step_1.data.number%'
132
+
133
+ steps:` ) ;
114
134
115
135
STEPS . map ( ( step , i ) => {
116
136
// The markdown string to look for in the comment from github-actions[bot]
117
137
const expectedString = `Results for \`${ step . queryFile } \`: **correct** (${ step . expectedResults } result${ step . expectedResults === 1 ? '' : 's' } )` ;
138
+ const expectedIssue = `Results for \`${ step . queryFile } \`:` ;
118
139
console . log ( `
119
140
- title: "${ escapeDoubleQuoteYamlString ( step . title ) } "
120
141
description: "${ escapeDoubleQuoteYamlString ( step . description ) } "
@@ -126,12 +147,25 @@ STEPS.map((step, i) => {
126
147
left: '%payload.sender.login%'
127
148
operator: ===
128
149
right: github-actions[bot]
150
+ # Ensure comment is relevant for this issue
151
+ - type: gate
152
+ left: '%payload.comment.body%'
153
+ operator: search
154
+ # regex-escape then yaml-escape the expected markdown string
155
+ right: "/${ escapeDoubleQuoteYamlString ( escapeRegExp ( expectedIssue ) ) } /"
129
156
# Ensure comment has expected completed string
130
157
- type: gate
131
158
left: '%payload.comment.body%'
132
159
operator: search
133
160
# regex-escape then yaml-escape the expected markdown string
134
161
right: "/${ escapeDoubleQuoteYamlString ( escapeRegExp ( expectedString ) ) } /"
162
+ else:
163
+ - type: respond
164
+ issue: "${ escapeDoubleQuoteYamlString ( issueTitle ( step , i ) ) } "
165
+ with: ${ FAIL_MESSAGE }
166
+ data:
167
+ commit: '%payload.comment.commit_id%'
168
+ commentUrl: '%payload.comment.html_url%'
135
169
136
170
# Answer is correct!!` ) ;
137
171
@@ -182,8 +216,17 @@ STEPS.map((step, i) => {
182
216
# Create Issue for next task
183
217
- type: createIssue
184
218
title: "${ escapeDoubleQuoteYamlString ( issueTitle ( next , i + 1 ) ) } "
185
- body: ${ next . instructionsFile }
186
- action_id: next_issue
219
+ body: ${ next . instructionsFile } ` ) ;
220
+ if ( next . activitiesFiles . length > 0 ) {
221
+ console . log ( ` comments:` ) ;
222
+ }
223
+ next . activitiesFiles . map ( file => {
224
+ console . log ( ` - ${ file } ` )
225
+ } )
226
+ console . log ( ` action_id: next_issue
227
+
228
+ - type: assignRegistrant
229
+ issue: '%actions.next_issue.data.number%'
187
230
188
231
# Make comment on current issue with link to commit that introduces correct query
189
232
- type: respond
0 commit comments