Skip to content

Commit 5b3980a

Browse files
feat: update start-exercise workflow to replace README with template message (#21)
* feat: update start-exercise workflow to generate README from template * fix: update help links in exercise-started README template to be more generic * feat: add dynamic link to exercise in README template * Use clearer variable name * Simplify start message * fix: update reference in start-exercise workflow to use version v0.2.0 --------- Co-authored-by: Christopher W. Blake <[email protected]>
1 parent 9778c41 commit 5b3980a

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

.github/workflows/start-exercise.yml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,35 +102,27 @@ jobs:
102102
steps:
103103
- uses: actions/checkout@v4
104104

105-
- name: Deactivate 'Copy Exercise' button
106-
run: |
107-
# Remove href from 'Copy Exercise' button
108-
target='id="copy-exercise"[^>]*href="[^"]*"'
109-
replacement='id="copy-exercise"'
110-
sed -i "s|$target|$replacement|g" README.md
111-
112-
# Change color from green to gray
113-
target=Copy_Exercise-008000
114-
replacement=Copy_Exercise-AAA
115-
sed -i "s|$target|$replacement|g" README.md
116-
117-
- name: Activate 'Start Exercise' button
118-
run: |
119-
# Add link to issue
120-
target='id="start-exercise"'
121-
replacement='id="start-exercise" href="../../issues/${{ needs.create_exercise.outputs.issue-number }}"'
122-
sed -i "s|$target|$replacement|g" README.md
105+
- name: Get response templates
106+
uses: actions/checkout@v4
107+
with:
108+
repository: skills/exercise-toolkit
109+
path: exercise-toolkit
110+
ref: v0.2.0
123111

124-
# Change color from gray to green
125-
target=Start_Exercise-AAA
126-
replacement=Start_Exercise-008000
127-
sed -i "s|$target|$replacement|g" README.md
112+
- name: Build welcome message from template
113+
id: build-new-readme
114+
uses: skills/action-text-variables@v1
115+
with:
116+
template-file: exercise-toolkit/markdown-templates/readme/exercise-started.md
117+
template-vars: |
118+
title=${{ inputs.exercise-title }}
119+
login=${{ github.actor }}
120+
issue_url=${{ needs.create_exercise.outputs.issue-url }}
128121
129-
- name: Replace relative links
130-
run: |
131-
target=../../
132-
replacement=https://github.com/${{ github.repository }}/
133-
sed -i "s|$target|$replacement|g" README.md
122+
- name: Overwrite README
123+
env:
124+
README_TEXT: ${{ steps.build-new-readme.outputs.updated-text }}
125+
run: echo "$README_TEXT" > README.md
134126

135127
- name: Commit changes
136128
uses: EndBug/add-and-commit@v9
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# {{ title }}
2+
3+
<img src="https://octodex.github.com/images/Professortocat_v2.png" align="right" height="200px" />
4+
5+
Hey **{{ login }}**!
6+
7+
Mona here. I'm done preparing your exercise. Hope you enjoy! 💚
8+
9+
Remember, it's self-paced so feel fee to take a break! ☕️
10+
11+
[![](https://img.shields.io/badge/Go%20to%20Exercise-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)]({{{ issue_url }}})
12+
13+
---
14+
15+
Get help: [Post in our discussion board](https://github.com/orgs/skills/discussions/categories/) &bull; [Review the GitHub status page](https://www.githubstatus.com/)
16+
17+
&copy; 2025 GitHub &bull; [Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md) &bull; [MIT License](https://gh.io/mit)

0 commit comments

Comments
 (0)