Skip to content

Commit 4f17cb3

Browse files
refactor: replace find exercise job with reusable workflow (#22)
1 parent 840da34 commit 4f17cb3

File tree

6 files changed

+14
-147
lines changed

6 files changed

+14
-147
lines changed

.github/workflows/1-preparing.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,8 @@ env:
1515

1616
jobs:
1717
find_exercise:
18-
name: Find exercise by issue title
19-
runs-on: ubuntu-latest
20-
21-
outputs:
22-
issue-url: ${{ steps.get-issue-url-by-title.outputs.ISSUE_URL }}
23-
24-
steps:
25-
- id: get-issue-url-by-title
26-
uses: actions/github-script@v7
27-
env:
28-
ISSUE_TITLE_PREFIX: "Exercise:"
29-
with:
30-
script: |
31-
const issues = await github.rest.issues.listForRepo({
32-
owner: context.repo.owner,
33-
repo: context.repo.repo,
34-
state: 'open',
35-
per_page: 1
36-
});
37-
38-
const issue = issues.data.find(issue => issue.title.includes(process.env.ISSUE_TITLE_PREFIX ));
39-
if (!issue) {
40-
throw new Error('No exercise issue found');
41-
}
42-
43-
core.setOutput('ISSUE_URL', issue.html_url);
18+
name: Find Exercise Issue
19+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
4420

4521
check_step_work:
4622
name: Check step work

.github/workflows/2-first-introduction.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,8 @@ env:
1717

1818
jobs:
1919
find_exercise:
20-
name: Find exercise by issue title
21-
runs-on: ubuntu-latest
22-
23-
outputs:
24-
issue-url: ${{ steps.get-issue-url-by-title.outputs.ISSUE_URL }}
25-
26-
steps:
27-
- id: get-issue-url-by-title
28-
uses: actions/github-script@v7
29-
env:
30-
ISSUE_TITLE_PREFIX: "Exercise:"
31-
with:
32-
script: |
33-
const issues = await github.rest.issues.listForRepo({
34-
owner: context.repo.owner,
35-
repo: context.repo.repo,
36-
state: 'open',
37-
per_page: 1
38-
});
39-
40-
const issue = issues.data.find(issue => issue.title.includes(process.env.ISSUE_TITLE_PREFIX ));
41-
if (!issue) {
42-
throw new Error('No exercise issue found');
43-
}
44-
45-
core.setOutput('ISSUE_URL', issue.html_url);
20+
name: Find Exercise Issue
21+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
4622

4723
check_step_work:
4824
name: Check step work

.github/workflows/3-copilot-edits.yml

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,8 @@ env:
1717

1818
jobs:
1919
find_exercise:
20-
name: Find exercise by issue title
21-
runs-on: ubuntu-latest
22-
23-
outputs:
24-
issue-url: ${{ steps.get-issue-url-by-title.outputs.ISSUE_URL }}
25-
26-
steps:
27-
- id: get-issue-url-by-title
28-
uses: actions/github-script@v7
29-
env:
30-
ISSUE_TITLE_PREFIX: "Exercise:"
31-
with:
32-
script: |
33-
const issues = await github.rest.issues.listForRepo({
34-
owner: context.repo.owner,
35-
repo: context.repo.repo,
36-
state: 'open',
37-
per_page: 1
38-
});
39-
40-
const issue = issues.data.find(issue => issue.title.includes(process.env.ISSUE_TITLE_PREFIX ));
41-
if (!issue) {
42-
throw new Error('No exercise issue found');
43-
}
44-
45-
core.setOutput('ISSUE_URL', issue.html_url);
20+
name: Find Exercise Issue
21+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
4622

4723
check_step_work:
4824
name: Check step work
@@ -108,7 +84,7 @@ jobs:
10884
checks=$(echo $checks | jq '.styles_css.message = "Please use Copilot to update the web application styling to support participant info."')
10985
fi
11086
111-
# Verify all checks passed
87+
# Verify all checks passed
11288
passed=$(echo $checks | jq '. | all(.passed?)')
11389
11490
# Flatten to an array for returning. Allows iteration during rendering.

.github/workflows/3b-copilot-agent-mode.yml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,8 @@ jobs:
3535
COMMENT_BODY: ${{ github.event.comment.body }}
3636

3737
find_exercise:
38-
name: Find exercise by issue title
39-
runs-on: ubuntu-latest
40-
41-
outputs:
42-
issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }}
43-
44-
steps:
45-
- id: get-issue-url
46-
run: |
47-
# Get the issue url from the event or search for it.
48-
if [ -n "${{ github.event.issue }}" ]; then
49-
issue_url="${{ github.event.issue.html_url }}"
50-
else
51-
issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url')
52-
fi
53-
54-
# Save to output
55-
echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT
56-
env:
57-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
REPO: ${{ github.repository }}
38+
name: Find Exercise Issue
39+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
5940

6041
post_step_3b_content:
6142
name: Post step 3b content

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,8 @@ env:
1717

1818
jobs:
1919
find_exercise:
20-
if: |
21-
!github.event.repository.is_template
22-
name: Find exercise by issue title
23-
runs-on: ubuntu-latest
24-
25-
outputs:
26-
issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }}
27-
28-
steps:
29-
- id: get-issue-url
30-
run: |
31-
# Get the issue url from the event or search for it.
32-
if [ -n "${{ github.event.issue }}" ]; then
33-
issue_url="${{ github.event.issue.html_url }}"
34-
else
35-
issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url')
36-
fi
37-
38-
# Save to output
39-
echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT
40-
env:
41-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
REPO: ${{ github.repository }}
20+
name: Find Exercise Issue
21+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
4322

4423
check_step_work:
4524
name: Check step work

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

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,8 @@ permissions:
2020

2121
jobs:
2222
find_exercise:
23-
if: |
24-
!github.event.repository.is_template
25-
name: Find exercise by issue title
26-
runs-on: ubuntu-latest
27-
28-
outputs:
29-
issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }}
30-
31-
steps:
32-
- id: get-issue-url
33-
run: |
34-
# Get the issue url from the event or search for it.
35-
if [ -n "${{ github.event.issue }}" ]; then
36-
issue_url="${{ github.event.issue.html_url }}"
37-
else
38-
issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url')
39-
fi
40-
41-
# Save to output
42-
echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT
43-
env:
44-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
REPO: ${{ github.repository }}
23+
name: Find Exercise Issue
24+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
4625

4726
check_step_work:
4827
name: Check step work
@@ -100,7 +79,7 @@ jobs:
10079
checks=$(echo $checks | jq '.copilot_review.message = "Please request a review from Copilot."')
10180
fi
10281
103-
# Verify all checks passed
82+
# Verify all checks passed
10483
passed=$(echo $checks | jq '. | all(.passed?)')
10584
10685
# Flatten to an array for returning. Allows iteration during rendering.

0 commit comments

Comments
 (0)