Skip to content

Commit 843d325

Browse files
refactor: modify finish exercise workflow to overwrite README and use reusable workflow from exercise-toolkit (#31)
1 parent 4773401 commit 843d325

File tree

2 files changed

+10
-65
lines changed

2 files changed

+10
-65
lines changed

.github/workflows/0-start-exercise.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: |
1919
!github.event.repository.is_template
2020
name: Start Exercise
21-
uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.2.0
21+
uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.3.0
2222
with:
2323
exercise-title: "Getting Started with GitHub Copilot"
2424
intro-message: "Welcome to the exciting world of GitHub Copilot! 🚀 In this exercise, you'll unlock the potential of this AI-powered coding assistant to accelerate your development process. Let's dive in and have some fun exploring the future of coding together! 💻✨"

.github/workflows/4-copilot-on-github.yml

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -75,76 +75,21 @@ jobs:
7575
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7676

7777
finish_exercise:
78-
name: Finish exercise
78+
name: Finish Exercise
79+
needs: [find_exercise, post_review_content]
80+
uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.3.0
81+
with:
82+
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
83+
84+
disable_workflow:
85+
name: Disable this workflow
7986
needs: [find_exercise, post_review_content]
8087
runs-on: ubuntu-latest
81-
env:
82-
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
8388

8489
steps:
8590
- name: Checkout
8691
uses: actions/checkout@v4
87-
with:
88-
ref: main
89-
90-
- name: Get response templates
91-
uses: actions/checkout@v4
92-
with:
93-
repository: skills/response-templates
94-
path: skills-response-templates
95-
96-
- name: Configure Git user
97-
run: |
98-
git config user.name github-actions[bot]
99-
git config user.email github-actions[bot]@users.noreply.github.com
100-
101-
- name: Build message - congratulations
102-
id: build-message-congratulations
103-
uses: skills/action-text-variables@v1
104-
with:
105-
template-file: skills-response-templates/readme/congratulations.md
106-
template-vars: |
107-
login=${{ github.actor }}
108-
109-
- name: Update README - congratulations
110-
run: |
111-
# Add "Congratulations" to the start of the README
112-
orig_readme=$(cat README.md)
113-
new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme"
114-
115-
# Update file and push
116-
echo "$new_readme" > README.md
117-
git add README.md
118-
git commit --message="Congratulations!🎉"
119-
git push
120-
env:
121-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122-
123-
- name: Build message - exercise finished
124-
id: build-finish-message
125-
uses: skills/action-text-variables@v1
126-
with:
127-
template-file: skills-response-templates/step-feedback/lesson-finished.md
128-
template-vars: |
129-
login=${{ github.actor }}
130-
repo_full_name=${{ github.repository }}
131-
132-
- name: Create comment - exercise finished
133-
run: |
134-
gh issue comment "$ISSUE_URL" \
135-
--body "$ISSUE_BODY"
136-
env:
137-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
138-
ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }}
139-
140-
- name: Close issue
141-
run: gh issue close "$ISSUE_URL"
142-
env:
143-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144-
14592
- name: Disable current workflow
146-
run: |
147-
gh workflow disable "Step 4"
148-
gh workflow disable "Step 4b"
93+
run: gh workflow disable "${{github.workflow}}"
14994
env:
15095
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)