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

Commit 61b5076

Browse files
authored
Merge pull request #15 from githubtraining/add-cli-pref
WIP: Add a CLI course pref
2 parents 2caef2d + 9d33d09 commit 61b5076

File tree

5 files changed

+125
-21
lines changed

5 files changed

+125
-21
lines changed

config.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ template:
55
name: "github-slideshow"
66
repo: "caption-this-template"
77
description: "A robot powered training repository :robot:"
8+
preferences:
9+
- type: radio
10+
name: gitTool
11+
label: Preferred Git tool
12+
description: Learn right from the web UI, or using your chosen tool
13+
options:
14+
- label: Use the github.com web interface
15+
value: dotcom
16+
- label: Use the command line
17+
value: cli
818
before:
919
- type: updateBranchProtection
1020
- type: createIssue
@@ -34,21 +44,23 @@ steps:
3444
issue: "Getting Started with GitHub"
3545
with: "close-issue.md"
3646

37-
- title: "Close an issue"
38-
description: "Cease a conversation by closing an issue."
39-
event: "issues.closed"
47+
- title: Close an issue
48+
description: Cease a conversation by closing an issue.
49+
event: issues.closed
4050
link: https://github.com/{{ user.username }}/{{ course.template.name }}/issues/1
4151
actions:
4252
- type: createIssue
4353
action_id: contrib_issue
44-
title: "Your first contribution"
45-
body: "your-first-contribution.md"
54+
title: Your first contribution
55+
body: your-first-contribution.md
4656
comments:
47-
- "create-a-branch.md"
57+
- create-a-branch.md
58+
data:
59+
thePayload: '%payload%'
4860
- type: respond
49-
with: "head-to-branch.md"
61+
with: head-to-branch.md
5062
data:
51-
issueURL: "%actions.contrib_issue.data.html_url%"
63+
issueURL: '%actions.contrib_issue.data.html_url%'
5264

5365
- title: "Create a branch"
5466
description: "Create a branch for introducing new changes."
@@ -57,9 +69,9 @@ steps:
5769
actions:
5870
- type: respond
5971
issue: "Your first contribution"
60-
with: "commit-something.md"
72+
with: commit-something.md
6173
data:
62-
branch: "%payload.ref%"
74+
thePayload: '%payload%'
6375

6476
- title: "Commit a file"
6577
description: "Commit your file to the branch."
@@ -125,6 +137,8 @@ steps:
125137
- type: createReview
126138
body: request-changes.md
127139
event: 'COMMENT'
140+
data:
141+
branch: '%payload.pull_request.head.ref%'
128142

129143

130144
- title: "Respond to a review"
@@ -156,6 +170,8 @@ steps:
156170
- type: createReview
157171
body: pr-succeeds.md
158172
event: APPROVE
173+
data:
174+
branch: '%payload.pull_request.head.ref%'
159175

160176
- title: "Merge your pull request"
161177
description: "Make your changes live by merging your PR."

responses/commit-something.md

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,49 @@ In the first field, type a commit message. The commit message should briefly tel
2626

2727
The following steps will guide you through the process of committing a change on GitHub.
2828

29+
{% if preferences.gitTool == 'cli' %}
30+
1. Check out to your branch:
31+
```shell
32+
git checkout {{ thePayload.ref }}
33+
```
34+
1. Create a new file named `_posts/0000-01-02-{{ user.username }}.md`.
35+
1. Add the following content to your file:
36+
```yaml
37+
---
38+
layout: slide
39+
title: "Welcome to our second slide!"
40+
---
41+
Your text
42+
Use the left arrow to go back!
43+
```
44+
1. Stage your new file:
45+
```shell
46+
git add _posts/0000-01-02-{{ user.username }}.md
47+
```
48+
1. After adding the text, commit the change and a commit message, check out the **Commits 101** drop-down, just above these instructions:
49+
```shell
50+
git commit -m "<YOUR-MESSAGE>"
51+
```
52+
1. Push your new commit to GitHub:
53+
```shell
54+
git push
55+
```
56+
{% else %}
2957
1. Return to the "Code" tab
30-
1. In the branch drop-down, select "{{ branch }}"
58+
1. In the branch drop-down, select "{{ thePayload.ref }}"
3159
1. Click **Create new file**
3260
1. In the "file name" field, type `_posts/0000-01-02-{{ user.username }}.md`
3361
1. When you’re done naming the file, add the following content to your file:
34-
35-
---
36-
layout: slide
37-
title: "Welcome to our second slide!"
38-
---
39-
Your text
40-
Use the left arrow to go back!
41-
42-
62+
```yaml
63+
---
64+
layout: slide
65+
title: "Welcome to our second slide!"
66+
---
67+
Your text
68+
Use the left arrow to go back!
69+
```
4370
1. After adding the text, you can commit the change by entering a commit message in the text-entry field below the file edit view. For guidelines on commit messages, check out the **Commits 101** drop-down, just above these instructions
4471
1. When you’ve entered a commit message, click **Commit new file**
45-
72+
{% endif %}
4673
<hr>
4774
<h3 align="center">Return to this issue for my response</h3>

responses/create-a-branch.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,31 @@ The best way to keep branches organized with a team is to keep them concise and
2323

2424
### :keyboard: Activity: Your first branch
2525

26+
{% if preferences.gitTool == 'cli' %}
27+
1. Open your preferred command line interface, which we'll call your shell from now on.
28+
1. Clone this repository:
29+
```shell
30+
git clone {{ thePayload.repository.clone_url }}
31+
```
32+
1. Navigate to the repository in your shell:
33+
```shell
34+
cd {{ thePayload.repository.name }}
35+
```
36+
1. Create a branch, use whatever name you like:
37+
```shell
38+
git branch <BRANCH-NAME>
39+
```
40+
1. Push the branch to GitHub:
41+
```
42+
git push --set-upstream origin <BRANCH-NAME>
43+
```
44+
{% else %}
45+
2646
1. Navigate to the “Code” tab
2747
2. Click **Branch: master** in the drop-down
2848
3. In the field, enter a name for your branch
2949
4. Click **Create branch: <name>** or press the “Enter” key to create your branch
3050

51+
{% endif %}
3152
<hr>
3253
<h3 align="center">Return to this issue for my response</h3>

responses/pr-succeeds.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,27 @@ You successfully created a pull request, and it has passed all of the tests. You
66

77
### :keyboard: Activity: Merge the pull request
88

9+
{% if preferences.gitTool == 'cli' %}
10+
1. Check out to the `master` branch:
11+
```shell
12+
git checkout master
13+
```
14+
2. Merge your branch:
15+
```shell
16+
git merge {{ branch }}
17+
```
18+
3. Push the merged history to GitHub:
19+
```shell
20+
git push
21+
```
22+
4. Delete your the branch locally:
23+
```shell
24+
git branch -d {{ branch }}
25+
```
26+
{% else %}
927
1. Click **Merge pull request**
1028
1. Click **Confirm merge**
29+
{% endif %}
1130
1. Once your branch has been merged, you don't need it anymore. Click **Delete branch**.
1231
1332
<hr>

responses/request-changes.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,31 @@ Let’s add some content to your file. Replace line 5 of your file with a quotat
66

77
### :keyboard: Activity: Change your file
88

9+
{% if preferences.gitTool == 'cli' %}
10+
1. Check out to your branch:
11+
```shell
12+
git checkout {{ branch }}
13+
```
14+
1. Open the file `_posts/0000-01-02-{{ user.username }}.md`.
15+
1. Replace line 5 of the file with something new.
16+
1. Stage your new changes:
17+
```shell
18+
git add _posts/0000-01-02-{{ user.username }}.md
19+
```
20+
1. Commit your changes:
21+
```shell
22+
git commit -m "<YOUR-MESSAGE>"
23+
```
24+
1. Push your edits to GitHub:
25+
```shell
26+
git push
27+
```
28+
{% else %}
929
1. Click the "Files Changed" tab in this pull request
1030
1. Click on the pencil icon found on the right side of the screen
1131
1. Replace line 5 with something new
1232
1. Scroll to the bottom and click **Commit Changes**
33+
{% endif %}
1334

1435
<hr>
1536
<h3 align="center">Watch below for my response</h3>

0 commit comments

Comments
 (0)