Skip to content

Migrate Skills Exercise from README -> Issue based flow #59

Migrate Skills Exercise from README -> Issue based flow

Migrate Skills Exercise from README -> Issue based flow #59

name: Step 3, Fix broken sidebar
# This step listens for the learner opening, editing, or reopening a pull request.
# This workflow updates from step 3 to step X.
# This will run every time we open, edit, or reopen the pull request.
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
pull_request:
branches:
- main
types:
- opened
- edited
- reopened
- closed
permissions:
# Need `contents: read` to checkout the repository.
# Need `contents: write` to update the step metadata.
contents: write
actions: write
issues: write
env:
REVIEW_FILE: ".github/steps/X-finish.md"
jobs:
find_exercise:
name: Find Exercise Issue
# We'll use the skills/exercise-toolkit to find the exercise issue.
uses: skills/exercise-toolkit/.github/workflows/[email protected]
check_step_work:
name: Check step work
runs-on: ubuntu-latest
needs: find_exercise
if: |
!github.event.repository.is_template &&
github.head_ref == 'fix-sidebar' &&
github.event.pull_request.merged == true
env:
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Get the response templates from the exercise-toolkit repository.
- name: Get response templates
uses: actions/checkout@v4
with:
repository: skills/exercise-toolkit
path: exercise-toolkit
ref: v0.3.0
- name: Dump GitHub pull request context
id: github_pull_request_step
run: echo '${{ toJSON(github.event.pull_request) }}'
- name: Check if the PR body is containing the required closing message
if: contains(github.event.pull_request.body, 'Closes')
run: echo "Found _Closes_ message with autolinked issue in the body of PR $NUMBER"
env:
NUMBER: ${{ github.event.pull_request.number }}
- name: Update comment - step finished - final review next
run: |
gh issue comment "$ISSUE_URL" \
--body-file exercise-toolkit/markdown-templates/step-feedback/checking-work.md \
--edit-last
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
post_review_content:
name: Post review content
needs: [find_exercise, check_step_work]
runs-on: ubuntu-latest
if: |
!github.event.repository.is_template
env:
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create comment - add review content
run: |
gh issue comment "$ISSUE_URL" \
--body-file ${{ env.REVIEW_FILE }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
finish_exercise:
name: Finish Exercise
needs: [find_exercise, post_review_content]
uses: skills/exercise-toolkit/.github/workflows/[email protected]
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
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Disable current workflow
run: gh workflow disable "${{github.workflow}}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}