Skip to content

refactor: modify finish exercise workflow to overwrite README and use reusable workflow from exercise-toolkit #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/0-start-exercise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
if: |
!github.event.repository.is_template
name: Start Exercise
uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.2.0
uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.3.0
with:
exercise-title: "Getting Started with GitHub Copilot"
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! 💻✨"
Expand Down
73 changes: 9 additions & 64 deletions .github/workflows/4-copilot-on-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,76 +75,21 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

finish_exercise:
name: Finish exercise
name: Finish Exercise
needs: [find_exercise, post_review_content]
uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.3.0
with:
issue-url: ${{ needs.find_exercise.outputs.issue-url }}

disable_workflow:
name: Disable this workflow
needs: [find_exercise, post_review_content]
runs-on: ubuntu-latest
env:
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main

- name: Get response templates
uses: actions/checkout@v4
with:
repository: skills/response-templates
path: skills-response-templates

- name: Configure Git user
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com

- name: Build message - congratulations
id: build-message-congratulations
uses: skills/action-text-variables@v1
with:
template-file: skills-response-templates/readme/congratulations.md
template-vars: |
login=${{ github.actor }}

- name: Update README - congratulations
run: |
# Add "Congratulations" to the start of the README
orig_readme=$(cat README.md)
new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme"

# Update file and push
echo "$new_readme" > README.md
git add README.md
git commit --message="Congratulations!🎉"
git push
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build message - exercise finished
id: build-finish-message
uses: skills/action-text-variables@v1
with:
template-file: skills-response-templates/step-feedback/lesson-finished.md
template-vars: |
login=${{ github.actor }}
repo_full_name=${{ github.repository }}

- name: Create comment - exercise finished
run: |
gh issue comment "$ISSUE_URL" \
--body "$ISSUE_BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }}

- name: Close issue
run: gh issue close "$ISSUE_URL"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Disable current workflow
run: |
gh workflow disable "Step 4"
gh workflow disable "Step 4b"
run: gh workflow disable "${{github.workflow}}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}