Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit 090d929

Browse files
authored
Merge pull request #8 from githubtraining/responses
Improve responses
2 parents 06e10eb + a8324ae commit 090d929

30 files changed

Lines changed: 294 additions & 43 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Take this course if you'd like to learn how to write and publish your own course on GitHub Learning Lab.
2+
3+
:warning: You'll need to be a owner of **{{ owner }}** in order to publish the course you create.

config.yml

Lines changed: 129 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
# Metadata for your course
2-
31
title: Write a Learning Lab course
42
tagline: Write a Learning Lab course
53
description: Write a Learning Lab course
64
template:
75
name: lab-starter
86
repo: write-a-ll-course-template
9-
10-
# `before` block
11-
# Actions to take place after the learner registers, but before they start interacting with their repo
12-
137
before:
148
- type: createIssue
159
title: Welcome
1610
body: welcome.md
1711
data:
1812
prUrl: '%payload.repository.html_url%/compare/master...add-metadata?expand=1'
19-
# Steps for the course
20-
# A list of steps that take the learner through the course
21-
2213
steps:
2314

2415
# 1
2516
- title: Open a PR to begin crafting your course
2617
description: Open a PR to begin crafting your course
2718
event: pull_request.opened
2819
actions:
20+
- type: gate
21+
left: '%payload.pull_request.head.ref%'
22+
operator: ===
23+
right: add-metadata
24+
else:
25+
- type: respond
26+
with: e-branch.md
2927
- type: respond
3028
with: add-title.md
3129
- type: octokit
@@ -46,6 +44,16 @@ steps:
4644
description: Give your course a title
4745
event: pull_request.synchronize
4846
actions:
47+
- type: getFileContents
48+
action_id: fileContents
49+
filename: 'config.yml'
50+
- type: gate
51+
left: '/^title: *\w(?![ \t]*#).*$/gm'
52+
operator: test
53+
right: '%actions.fileContents%'
54+
else:
55+
- type: respond
56+
with: e-no-title.md
4957
- type: respond
5058
with: add-template.md
5159
- type: octokit
@@ -66,6 +74,16 @@ steps:
6674
description: Point to the template repo
6775
event: pull_request.synchronize
6876
actions:
77+
- type: getFileContents
78+
action_id: fileContents
79+
filename: 'config.yml'
80+
- type: gate
81+
left: '/^ repo: *lab-starter-template(?!#).*$/gm'
82+
operator: test
83+
right: '%actions.fileContents%'
84+
else:
85+
- type: respond
86+
with: e-no-repo.md
6987
- type: respond
7088
with: add-repo-name.md
7189
- type: octokit
@@ -86,6 +104,16 @@ steps:
86104
description: Give the learner's repo a name
87105
event: pull_request.synchronize
88106
actions:
107+
- type: getFileContents
108+
action_id: fileContents
109+
filename: 'config.yml'
110+
- type: gate
111+
left: '/^ name: *\w(?![ \t]*#).*$/gm'
112+
operator: test
113+
right: '%actions.fileContents%'
114+
else:
115+
- type: respond
116+
with: e-no-name.md
89117
- type: respond
90118
with: create-issue.md
91119
- type: octokit
@@ -130,6 +158,16 @@ steps:
130158
description: Create an issue using Learning Lab
131159
event: pull_request.synchronize
132160
actions:
161+
- type: getFileContents
162+
action_id: fileContents
163+
filename: 'config.yml'
164+
- type: gate
165+
left: '/^- type: *createIssue(?!#).*$\n title: *(?![ \t]*#).*$\n. body: *welcome-text.md(?!#).*$/gm'
166+
operator: test
167+
right: '%actions.fileContents%'
168+
else:
169+
- type: respond
170+
with: e-no-new-issue.md
133171
- type: respond
134172
with: add-response.md
135173

@@ -149,6 +187,16 @@ steps:
149187
else:
150188
type: respond
151189
with: e-no-response.md
190+
- type: getFileContents
191+
action_id: fileContents
192+
filename: 'responses/welcome-text.md'
193+
- type: gate
194+
left: '/\w+/gm'
195+
operator: test
196+
right: '%actions.fileContents%'
197+
else:
198+
- type: respond
199+
with: e-no-response.md
152200
- type: respond
153201
with: add-first-step.md
154202
- type: octokit
@@ -181,6 +229,16 @@ steps:
181229
description: Name your first step and give it a description
182230
event: pull_request.synchronize
183231
actions:
232+
- type: getFileContents
233+
action_id: fileContents
234+
filename: 'config.yml'
235+
- type: gate
236+
left: '/^ description:(?![ \t]*#).*$/gm'
237+
operator: test
238+
right: '%actions.fileContents%'
239+
else:
240+
- type: respond
241+
with: e-no-step-title.md
184242
- type: respond
185243
with: add-trigger.md
186244
- type: octokit
@@ -201,6 +259,16 @@ steps:
201259
description: Trigger your first step with a GitHub event
202260
event: pull_request.synchronize
203261
actions:
262+
- type: getFileContents
263+
action_id: fileContents
264+
filename: 'config.yml'
265+
- type: gate
266+
left: '/^ event: *pull_request.opened(?!#).*$/gm'
267+
operator: test
268+
right: '%actions.fileContents%'
269+
else:
270+
- type: respond
271+
with: e-no-event.md
204272
- type: respond
205273
with: validate.md
206274
- type: octokit
@@ -221,6 +289,16 @@ steps:
221289
description: Validate a learner's PR
222290
event: pull_request.synchronize
223291
actions:
292+
- type: getFileContents
293+
action_id: fileContents
294+
filename: 'config.yml'
295+
- type: gate
296+
left: '/^ - type: *gate(?!#).*$/gm'
297+
operator: test
298+
right: '%actions.fileContents%'
299+
else:
300+
- type: respond
301+
with: e-no-gate.md
224302
- type: respond
225303
with: add-context.md
226304
- type: octokit
@@ -232,7 +310,7 @@ steps:
232310
path: config.yml
233311
body: |
234312
```suggestion
235-
left: '%payload.pull_request.title%'
313+
left: # replace me without spaces: ' % payload.pull_request.title % '
236314
```
237315
position: 41
238316
- type: octokit
@@ -265,6 +343,16 @@ steps:
265343
description: Use contextual information to validate
266344
event: pull_request.synchronize
267345
actions:
346+
# - type: getFileContents
347+
# action_id: fileContents
348+
# filename: 'config.yml'
349+
# - type: gate
350+
# left: '/^ left: *'%payload.pull_request.title%'(?!#).*$\n operator: *===(?!#).*$\n. right: *Add name to README(?!#).*$/gm'
351+
# operator: test
352+
# right: '%actions.fileContents%'
353+
# else:
354+
# - type: respond
355+
# with: e-no-gate-options.md
268356
- type: respond
269357
with: respond-success.md
270358
- type: octokit
@@ -297,6 +385,16 @@ steps:
297385
description: Respond to a learner's successful PR
298386
event: pull_request.synchronize
299387
actions:
388+
- type: getFileContents
389+
action_id: fileContents
390+
filename: 'config.yml'
391+
- type: gate
392+
left: '/^ - type: *respond(?!#).*$\n with: *pr-opened.md(?!#).*$/gm'
393+
operator: test
394+
right: '%actions.fileContents%'
395+
else:
396+
- type: respond
397+
with: e-no-respond-action.md
300398
- type: respond
301399
with: add-descriptions.md
302400
- type: octokit
@@ -329,6 +427,16 @@ steps:
329427
description: Add some descriptions to your course
330428
event: pull_request.synchronize
331429
actions:
430+
- type: getFileContents
431+
action_id: fileContents
432+
filename: 'config.yml'
433+
- type: gate
434+
left: '/^tagline:(?![ \t]*#).*$\ndescription:(?![ \t]*#).*$/gm'
435+
operator: test
436+
right: '%actions.fileContents%'
437+
else:
438+
- type: respond
439+
with: e-no-meta.md
332440
- type: respond
333441
with: add-readme.md
334442

@@ -337,6 +445,17 @@ steps:
337445
description: Add a README to your course
338446
event: pull_request.synchronize
339447
actions:
448+
- type: getTree
449+
action_id: tree
450+
recursive: true
451+
sha: '%payload.pull_request.head.sha%'
452+
- type: gate
453+
left: '%actions.tree.data.tree%'
454+
operator: includes
455+
right: path:README.md
456+
else:
457+
type: respond
458+
with: e-no-readme.md
340459
- type: respond
341460
with: publish.md
342461

responses/add-context.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ We need to validate against the learner's pull request title. This information i
22

33
We'll add the `left:` option to the gate, and set it to the pull request's title.
44

5-
Activity:
5+
### :keyboard: Activity: Adding validation
6+
67
1. Add a `left:` option to the gate
78
1. Set the gate's `left:` option to the pull request's title which is `'%payload.pull_request.title%'`.
89
1. Set the gate's `operator:` to `===`
910
1. Set the gate's `right:` to the title we expect which is `Add name to README`
1011

11-
You can also accept the suggested changes below. They're in batch, so you'll have to go to Files Changed.
12+
You can also accept the suggested changes below. They're in batch, so you'll have to go to Files Changed.
13+
14+
<hr>
15+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-descriptions.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
Remember your course's metadata, near the top of your config? We left the description and tagline but it's not time to fill it in.
22

3-
Accept the suggested changes below or change the lines manually.
3+
### :keyboard: Activity: Accept the suggested changes
4+
5+
Click `Accept suggested change` below or change the lines manually.
6+
7+
<hr>
8+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-first-step.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
Great! The learner's repo will now be setup. Let's now dive into the `steps:`. This block is composed of steps that are triggered by `events` on GitHub, and in turn certain `actions` take place.
1+
Great! The learner's repo will now be setup. Let's now dive into the `steps:`. This block is composed of steps that are triggered by `events` on GitHub, and in turn certain `actions` take place.
22

33
Note: `actions` in this context is NOT the same as GitHub Actions.
44

5-
Let's name our first step.
5+
Let's name our first step.
6+
7+
8+
### :keyboard: Activity: Naming our first step
9+
10+
11+
<hr>
12+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
The last thing that remains is a README. This file is show no the course's page, whenever the learner is thinking of registering. Typically this file should contain learning outcomes and some long form content.
1+
The last thing that remains is a README. This file is show no the course's page, whenever the learner is thinking of registering. Typically this file should contain learning outcomes and some long form content.
22

3-
We added a README for you, but go ahead and put in your own content.
3+
### :keyboard: Activity: Edit the README.md
4+
5+
- We added a README for you, but go ahead and put in your own content.
6+
7+
<hr>
8+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-repo-name.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
Awesome! The learner's repo will now be cloned from `lab-starter-template`. We probably don't want that to be the learner's repo name though, so let's ensure that the learner-facing name is better.
1+
Awesome! The learner's repository will now be cloned from `lab-starter-template`. We probably don't want that to be the learner's repo name though, so let's ensure that the learner-facing name is better.
22

3-
Change the field `name:` as part of the `template:` section to anything you like. You can also accept the suggestion below.
3+
### :keyboard: Activity: Update the repository name
4+
5+
Change the field `name:` as part of the `template:` section to anything you like. You can also accept the suggestion below.
6+
7+
<hr>
8+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-response.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
Great, we referenced a file title `welcome-text.md`, but it doesn't exist. Learning Lab automatically looks in the `responses/` directory for all content files. Let's add it.
22

3-
Activity: add a response
3+
### :keyboard: Activity: Adding a response
44

55
1. In the `/responses/` folder, create a new file titled `welcome-text.md`
6-
1. In that file, add some content that will appear to the learner in the welcome issue.
7-
1. Add an instruction for the learner to open a new PR titled "Add name to README" in which they add their name to the README file.
6+
1. In that file, add some content that will appear to the learner in the welcome issue.
7+
1. Add an instruction for the learner to open a new PR titled "Add name to README" in which they add their name to the README file.
8+
9+
<hr>
10+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-template.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
Great! The title will appear anywhere the course is referenced. We'll fill in some more of the course metadata later. Let's get into its nuts and bolts though.
1+
Great! The title will appear anywhere the course is referenced. We'll fill in some more of the course metadata later. Let's get into its nuts and bolts though.
22

3-
Most courses make use of a template repo. Template repos are cloned for the learner and can contain starter code or resources to help them find their way.
3+
Most courses make use of a template repo. Template repos are cloned for the learner and can contain starter code or resources to help them find their way.
44

55
Let's add our own template repo. To speed things up, we've created a template repo for you. We recommend going with this one.
66

7-
You can edit the file directly or accept the suggested change below.
7+
You can edit the file directly or accept the suggested change below.
8+
9+
### :keyboard: Activity: Add a template repo
10+
11+
12+
<hr>
13+
<h3 align="center">I'll respond below with your next step.</h3>

responses/add-title.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
Great! You opened the PR.
22

3-
Now let's give your course a title. You can do so by editing `config.yml` directly and changing the title field, or accepting the suggestion below.
3+
Now let's give your course a title. You can do so by editing `config.yml` directly and changing the title field, or accepting the suggestion below.
4+
5+
### :keyboard: Activity: Give your course a title
6+
7+
8+
<hr>
9+
<h3 align="center">I'll respond below with your next step.</h3>

0 commit comments

Comments
 (0)