Skip to content

Commit 876dcb5

Browse files
committed
feat: migrate exercise to issue-based flow
1 parent 170b5a2 commit 876dcb5

13 files changed

+387
-360
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/steps/-step.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/steps/0-welcome.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
<!--
2-
<<< Author notes: Step 1 >>>
3-
Choose 3-5 steps for your course.
4-
The first step is always the hardest, so pick something easy!
5-
Link to docs.github.com for further explanations.
6-
Encourage users to open new tabs for steps!
7-
-->
8-
91
## Step 1: Resolve duplicate issues
102

11-
_Welcome to the course :tada:_
12-
133
GitHub has special capabilities to help reference other information on GitHub. For example, when you reference another issue or pull request by number, that number will be hyperlinked. At the same time, a cross-reference is created in the linked issue or pull request. This two-way reference helps people track the relationship of information across GitHub.
144

155
![a screenshot of an issue linking to a PR, and a PR with a cross-reference to the issue](https://user-images.githubusercontent.com/6351798/172456846-2daec570-08b0-4ffa-a7cb-41acc50b836e.png)
@@ -24,6 +14,7 @@ When you want to create a crosslink, start typing the title of an issue or pull
2414

2515
### :keyboard: Activity: Find and close the cross-linked issue
2616

27-
1. Navigate to the issue #1 (Welcome)
28-
2. Type "Duplicate of #2" as a comment and close issue #1
29-
3. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
17+
1. Navigate to the issue #{{duplicate_issue}} (Welcome)
18+
2. Type "Duplicate of #{{original_issue}}" as a comment and close issue #{{duplicate_issue}}
19+
3. After you close the issue, Mona will prepare the next step in this exercise!
20+

.github/steps/2-find-commit-in-history.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
<!--
2-
<<< Author notes: Step 2 >>>
3-
Start this step by acknowledging the previous step.
4-
Define terms and link to docs.github.com.
5-
-->
6-
71
## Step 2: Find a commit in history
82

93
_Thanks for the duplicate note :wave:_
@@ -30,4 +24,4 @@ A SHA is a reference to a specific object. In this case, it's a reference to a c
3024
5. Click the commit message, `add sidebar to documentation` to see the commit details
3125
6. Copy the first seven characters of the SHA (the first 7 characters of the 40 character hexadecimal string listed after `commit`)
3226
7. Comment on issue #2 by adding the SHA from step 6 as a comment text and click on "Comment" button
33-
8. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
27+
8. After you comment on the issue, Mona will prepare the next step in this exercise!

.github/steps/3-fix-broken-sidebar.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
<!--
2-
<<< Author notes: Step 3 >>>
3-
Start this step by acknowledging the previous step.
4-
Define terms and link to docs.github.com.
5-
-->
6-
71
## Step 3: Fix a broken sidebar
82

93
_Great job finding that commit :heart:_
@@ -27,13 +21,16 @@ When you're looking at a commit on GitHub, you can see a lot of information. Fro
2721

2822
### :keyboard: Activity: Fix a broken sidebar
2923

30-
1. In the main branch [Edit the `docs/_sidebar.md` file](/docs/_sidebar.md).
24+
1. In the `main` branch, edit the `/docs/_sidebar.md` file.
3125
2. Correct the spelling of the reference `(doc-references__.md)` on line 4 by changing it into `(doc-references.md)`.
3226
3. Select or create a new branch `fix-sidebar` for this commit and start a pull request.
33-
4. Make sure that **main** is selected for **base:** and **fix-sidebar** for **compare:**.
34-
5. Using the **Assignees** section on the right side, assign yourself to the pull request.
35-
6. In the PR comment add 'Closes #2' and autolink issue #2.
27+
![image](https://github.com/user-attachments/assets/efa2c6b1-1d74-48c1-9337-14161dd0f914)
28+
29+
30+
4. Make sure that `main` is selected for `base:` and `fix-sidebar` for `compare:`.
31+
5. Using the `Assignees` section on the right side, assign yourself to the pull request.
32+
6. In the PR comment add `Closes #2` and autolink issue #2.
3633
7. Click **Create pull request** and wait about 20 seconds.
3734
8. Merge this pull request.
38-
9. Delete the branch 'fix-sidebar'.
39-
10. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.
35+
9. Delete the branch `fix-sidebar`.
36+
10. After you merge the PR and delete the branch, Mona will prepare the next step in this exercise!

.github/steps/X-finish.md renamed to .github/steps/x-finish.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
<!--
2-
<<< Author notes: Finish >>>
3-
Review what we learned, ask for feedback, provide next steps.
4-
-->
5-
6-
## Finish
7-
8-
_Congratulations friend, you've completed this course! :tada:_
1+
## Review
92

103
<img src="https://octodex.github.com/images/collabocats.jpg" alt=celebrate width=300 align=right>
114

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Step 0
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
issues: write
12+
13+
env:
14+
STEP_1_FILE: ".github/steps/1-resolve-duplicate-issues.md"
15+
16+
jobs:
17+
start_exercise:
18+
if: |
19+
!github.event.repository.is_template
20+
name: Start Exercise
21+
uses: skills/exercise-toolkit/.github/workflows/[email protected]
22+
with:
23+
exercise-title: "Connect the Dots"
24+
intro-message: "Let's learn to navigate a GitHub repository effectively!"
25+
26+
create_first_task:
27+
name: Create first task
28+
runs-on: ubuntu-latest
29+
needs: [start_exercise]
30+
env:
31+
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
32+
outputs:
33+
original_issue: ${{ steps.issue_a.outputs.original_issue }}
34+
duplicate_issue: ${{ steps.issue_b.outputs.duplicate_issue }}
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Create 'Fix broken sidebar' issue (target for duplicate)
41+
id: issue_a
42+
uses: actions/github-script@v7
43+
with:
44+
result-encoding: string
45+
script: |
46+
const { data: issue } = await github.rest.issues.create({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
title: "Fix the broken sidebar",
50+
body: "The sidebar in `docs/_sidebar.md` is broken and needs fixing."
51+
});
52+
core.setOutput("original_issue", issue.number);
53+
54+
- name: Create 'Duplicate report' issue (to be closed as duplicate)
55+
id: issue_b
56+
uses: actions/github-script@v7
57+
with:
58+
result-encoding: string
59+
script: |
60+
const { data: issue } = await github.rest.issues.create({
61+
owner: context.repo.owner,
62+
repo: context.repo.repo,
63+
title: "Sidebar bug again",
64+
body: "Looks like the sidebar bug was already reported."
65+
});
66+
core.setOutput("duplicate_issue", issue.number);
67+
68+
69+
prep_repo_content:
70+
name: Prep repo for next step
71+
runs-on: ubuntu-latest
72+
needs: [start_exercise, create_first_task]
73+
env:
74+
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
75+
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Prepare files history
81+
run: |
82+
echo "Make sure we are on step 0"
83+
if [ "${{ github.workflow }}" != "Step 0" ]
84+
then
85+
echo "Current step is not Step 0"
86+
exit 0
87+
fi
88+
git config user.name github-actions[bot]
89+
git config user.email github-actions[bot]@users.noreply.github.com
90+
git checkout main
91+
echo "Update _sidebar.md for the 1st time"
92+
cp -f .github/files/_sidebar01.md docs/_sidebar.md
93+
git add docs/_sidebar.md
94+
git commit -m "updated _sidebar.md"
95+
git pull --rebase origin main || true
96+
git push || true
97+
echo "update _sidebar.md for the 2nd time"
98+
cp -f .github/files/_sidebar02.md docs/_sidebar.md
99+
git add docs/_sidebar.md
100+
git commit -m "add sidebar to documentation"
101+
git push
102+
echo "preserve the commit shaw"
103+
git log --all --oneline | grep "add sidebar to documentation" | cut -c 1-7 >> .github/files/SIDEBARCOMMIT
104+
git add .github/files/SIDEBARCOMMIT
105+
git commit -m "created SIDEBARCOMMIT"
106+
git push
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109+
110+
post_next_step_content:
111+
name: Post next step content
112+
runs-on: ubuntu-latest
113+
needs: [start_exercise, create_first_task]
114+
env:
115+
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
116+
117+
steps:
118+
- name: Checkout
119+
uses: actions/checkout@v4
120+
121+
- name: Get response templates
122+
uses: actions/checkout@v4
123+
with:
124+
repository: skills/exercise-toolkit
125+
path: exercise-toolkit
126+
ref: v0.3.0
127+
128+
- name: Build comment - add step content
129+
id: build-comment
130+
uses: skills/action-text-variables@v1
131+
with:
132+
template-file: ${{ env.STEP_1_FILE }}
133+
template-vars: |
134+
full_repo_name=${{ github.repository }}
135+
original_issue=${{ needs.create_first_task.outputs.original_issue }}
136+
duplicate_issue=${{ needs.create_first_task.outputs.duplicate_issue }}
137+
138+
- name: Create comment - add step content
139+
run: |
140+
gh issue comment "$ISSUE_URL" \
141+
--body "$ISSUE_BODY"
142+
env:
143+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
ISSUE_BODY: ${{ steps.build-comment.outputs.updated-text }}
145+
146+
- name: Create comment - watching for progress
147+
run: |
148+
gh issue comment "$ISSUE_URL" \
149+
--body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
150+
env:
151+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
153+
- name: Enable next step workflow
154+
run: |
155+
gh workflow enable "Step 1"
156+
env:
157+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/0-welcome.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)