Skip to content

refactor: replace find exercise job with reusable workflow #22

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
Mar 28, 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
28 changes: 2 additions & 26 deletions .github/workflows/1-preparing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,8 @@ env:

jobs:
find_exercise:
name: Find exercise by issue title
runs-on: ubuntu-latest

outputs:
issue-url: ${{ steps.get-issue-url-by-title.outputs.ISSUE_URL }}

steps:
- id: get-issue-url-by-title
uses: actions/github-script@v7
env:
ISSUE_TITLE_PREFIX: "Exercise:"
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 1
});

const issue = issues.data.find(issue => issue.title.includes(process.env.ISSUE_TITLE_PREFIX ));
if (!issue) {
throw new Error('No exercise issue found');
}

core.setOutput('ISSUE_URL', issue.html_url);
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0

check_step_work:
name: Check step work
Expand Down
28 changes: 2 additions & 26 deletions .github/workflows/2-first-introduction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,8 @@ env:

jobs:
find_exercise:
name: Find exercise by issue title
runs-on: ubuntu-latest

outputs:
issue-url: ${{ steps.get-issue-url-by-title.outputs.ISSUE_URL }}

steps:
- id: get-issue-url-by-title
uses: actions/github-script@v7
env:
ISSUE_TITLE_PREFIX: "Exercise:"
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 1
});

const issue = issues.data.find(issue => issue.title.includes(process.env.ISSUE_TITLE_PREFIX ));
if (!issue) {
throw new Error('No exercise issue found');
}

core.setOutput('ISSUE_URL', issue.html_url);
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0

check_step_work:
name: Check step work
Expand Down
30 changes: 3 additions & 27 deletions .github/workflows/3-copilot-edits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,8 @@ env:

jobs:
find_exercise:
name: Find exercise by issue title
runs-on: ubuntu-latest

outputs:
issue-url: ${{ steps.get-issue-url-by-title.outputs.ISSUE_URL }}

steps:
- id: get-issue-url-by-title
uses: actions/github-script@v7
env:
ISSUE_TITLE_PREFIX: "Exercise:"
with:
script: |
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 1
});

const issue = issues.data.find(issue => issue.title.includes(process.env.ISSUE_TITLE_PREFIX ));
if (!issue) {
throw new Error('No exercise issue found');
}

core.setOutput('ISSUE_URL', issue.html_url);
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0

check_step_work:
name: Check step work
Expand Down Expand Up @@ -108,7 +84,7 @@ jobs:
checks=$(echo $checks | jq '.styles_css.message = "Please use Copilot to update the web application styling to support participant info."')
fi

# Verify all checks passed
# Verify all checks passed
passed=$(echo $checks | jq '. | all(.passed?)')

# Flatten to an array for returning. Allows iteration during rendering.
Expand Down
23 changes: 2 additions & 21 deletions .github/workflows/3b-copilot-agent-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,8 @@ jobs:
COMMENT_BODY: ${{ github.event.comment.body }}

find_exercise:
name: Find exercise by issue title
runs-on: ubuntu-latest

outputs:
issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }}

steps:
- id: get-issue-url
run: |
# Get the issue url from the event or search for it.
if [ -n "${{ github.event.issue }}" ]; then
issue_url="${{ github.event.issue.html_url }}"
else
issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url')
fi

# Save to output
echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0

post_step_3b_content:
name: Post step 3b content
Expand Down
25 changes: 2 additions & 23 deletions .github/workflows/4-copilot-on-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,8 @@ env:

jobs:
find_exercise:
if: |
!github.event.repository.is_template
name: Find exercise by issue title
runs-on: ubuntu-latest

outputs:
issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }}

steps:
- id: get-issue-url
run: |
# Get the issue url from the event or search for it.
if [ -n "${{ github.event.issue }}" ]; then
issue_url="${{ github.event.issue.html_url }}"
else
issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url')
fi

# Save to output
echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0

check_step_work:
name: Check step work
Expand Down
27 changes: 3 additions & 24 deletions .github/workflows/4b-copilot-on-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,8 @@ permissions:

jobs:
find_exercise:
if: |
!github.event.repository.is_template
name: Find exercise by issue title
runs-on: ubuntu-latest

outputs:
issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }}

steps:
- id: get-issue-url
run: |
# Get the issue url from the event or search for it.
if [ -n "${{ github.event.issue }}" ]; then
issue_url="${{ github.event.issue.html_url }}"
else
issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url')
fi

# Save to output
echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0

check_step_work:
name: Check step work
Expand Down Expand Up @@ -100,7 +79,7 @@ jobs:
checks=$(echo $checks | jq '.copilot_review.message = "Please request a review from Copilot."')
fi

# Verify all checks passed
# Verify all checks passed
passed=$(echo $checks | jq '. | all(.passed?)')

# Flatten to an array for returning. Allows iteration during rendering.
Expand Down