Skip to content

Commit 16ff271

Browse files
authored
Separate step 4 grading workflow into 2 files.
1 parent dc29477 commit 16ff271

File tree

3 files changed

+188
-125
lines changed

3 files changed

+188
-125
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ jobs:
204204
- name: Disable current workflow and enable next one
205205
run: |
206206
gh workflow disable "Step 3"
207-
gh workflow enable "Step 4"
207+
gh workflow enable "Step 4a"
208+
gh workflow enable "Step 4b"
208209
env:
209210
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Step 4a # Copilot on GitHub
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- closed
9+
10+
permissions:
11+
contents: write
12+
actions: write
13+
issues: write
14+
15+
env:
16+
REVIEW_FILE: ".github/steps/x-review.md"
17+
18+
jobs:
19+
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 }}
43+
44+
check_step_work:
45+
name: Check step work
46+
runs-on: ubuntu-latest
47+
needs: [find_exercise]
48+
env:
49+
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Get response templates
56+
uses: actions/checkout@v4
57+
with:
58+
repository: skills/response-templates
59+
path: skills-response-templates
60+
61+
# START: Check practical exercise
62+
63+
# Nothing to check. Merging the pull request is enough.
64+
65+
# END: Check practical exercise
66+
67+
- name: Create comment - step finished - final review next
68+
run: |
69+
gh issue comment "$ISSUE_URL" \
70+
--body-file skills-response-templates/step-feedback/lesson-review.md
71+
env:
72+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
post_review_content:
75+
name: Post review content
76+
needs: [find_exercise, check_step_work]
77+
runs-on: ubuntu-latest
78+
env:
79+
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
80+
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v4
84+
85+
- name: Get response templates
86+
uses: actions/checkout@v4
87+
with:
88+
repository: skills/response-templates
89+
path: skills-response-templates
90+
91+
- name: Create comment - add step content
92+
run: |
93+
gh issue comment "$ISSUE_URL" \
94+
--body-file "$REVIEW_FILE"
95+
env:
96+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
98+
finish_exercise:
99+
name: Finish exercise
100+
needs: [find_exercise, post_review_content]
101+
runs-on: ubuntu-latest
102+
env:
103+
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
104+
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@v4
108+
with:
109+
ref: main
110+
111+
- name: Get response templates
112+
uses: actions/checkout@v4
113+
with:
114+
repository: skills/response-templates
115+
path: skills-response-templates
116+
117+
- name: Configure Git user
118+
run: |
119+
git config user.name github-actions[bot]
120+
git config user.email github-actions[bot]@users.noreply.github.com
121+
122+
- name: Build message - congratulations
123+
id: build-message-congratulations
124+
uses: skills/action-text-variables@v1
125+
with:
126+
template-file: skills-response-templates/readme/congratulations.md
127+
template-vars: |
128+
login=${{ github.actor }}
129+
130+
- name: Update README - congratulations
131+
run: |
132+
# Add "Congratulations" to the start of the README
133+
orig_readme=$(cat README.md)
134+
new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme"
135+
136+
# Update file and push
137+
echo "$new_readme" > README.md
138+
git add README.md
139+
git commit --message="Congratulations!🎉"
140+
git push
141+
env:
142+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143+
144+
- name: Build message - exercise finished
145+
id: build-finish-message
146+
uses: skills/action-text-variables@v1
147+
with:
148+
template-file: skills-response-templates/step-feedback/lesson-finished.md
149+
template-vars: |
150+
login=${{ github.actor }}
151+
repo_full_name=${{ github.repository }}
152+
153+
- name: Create comment - exercise finished
154+
run: |
155+
gh issue comment "$ISSUE_URL" \
156+
--body "$ISSUE_BODY"
157+
env:
158+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }}
160+
161+
- name: Close issue
162+
run: gh issue close "$ISSUE_URL"
163+
env:
164+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165+
166+
- name: Disable current workflow
167+
run: |
168+
gh workflow disable "Step 4a"
169+
gh workflow disable "Step 4b"
170+
env:
171+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 15 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
name: Step 4 # Copilot on GitHub
1+
name: Step 4b # Copilot on GitHub
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
7-
types: [edited]
8-
pull_request_review:
4+
# Trigger if PR Description is edited
5+
# pull_request:
6+
# branches:
7+
# - main
8+
# types:
9+
# - edited
10+
11+
# Trigger if Copilot adds a review comment
12+
pull_request_review_comment:
13+
types:
14+
- created
915

1016
permissions:
1117
contents: write
@@ -14,9 +20,6 @@ permissions:
1420
pull-requests: read
1521
repository-projects: read
1622

17-
env:
18-
REVIEW_FILE: ".github/steps/x-review.md"
19-
2023
jobs:
2124
find_exercise:
2225
if: |
@@ -60,16 +63,9 @@ jobs:
6063
repository: skills/response-templates
6164
path: skills-response-templates
6265

63-
- name: Update comment - checking work
64-
run: |
65-
gh issue comment "$ISSUE_URL" \
66-
--body-file skills-response-templates/step-feedback/checking-work.md \
67-
--edit-last
68-
env:
69-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70-
7166
# START: Check practical exercise
72-
- name: Check participant info on activity cards
67+
68+
- name: Check for pr description and copilot review
7369
id: check-user-work
7470
run: |
7571
# Checks to perform
@@ -143,8 +139,7 @@ jobs:
143139
- name: Create comment - step results
144140
run: |
145141
gh issue comment "$ISSUE_URL" \
146-
--body "$COMMENT_BODY" \
147-
--edit-last
142+
--body "$COMMENT_BODY"
148143
env:
149144
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150145
COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }}
@@ -154,107 +149,3 @@ jobs:
154149
run: exit 1
155150

156151
# END: Check practical exercise
157-
158-
- name: Update comment - step finished - final review next
159-
run: |
160-
gh issue comment "$ISSUE_URL" \
161-
--body-file skills-response-templates/step-feedback/lesson-review.md
162-
env:
163-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164-
165-
post_review_content:
166-
name: Post review content
167-
needs: [find_exercise, check_step_work]
168-
runs-on: ubuntu-latest
169-
env:
170-
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
171-
172-
steps:
173-
- name: Checkout
174-
uses: actions/checkout@v4
175-
176-
- name: Get response templates
177-
uses: actions/checkout@v4
178-
with:
179-
repository: skills/response-templates
180-
path: skills-response-templates
181-
182-
- name: Create comment - add step content
183-
run: |
184-
gh issue comment "$ISSUE_URL" \
185-
--body-file "$REVIEW_FILE"
186-
env:
187-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188-
189-
finish_exercise:
190-
name: Finish exercise
191-
needs: [find_exercise, post_review_content]
192-
runs-on: ubuntu-latest
193-
env:
194-
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
195-
196-
steps:
197-
- name: Checkout
198-
uses: actions/checkout@v4
199-
with:
200-
ref: main
201-
202-
- name: Get response templates
203-
uses: actions/checkout@v4
204-
with:
205-
repository: skills/response-templates
206-
path: skills-response-templates
207-
208-
- name: Configure Git user
209-
run: |
210-
git config user.name github-actions[bot]
211-
git config user.email github-actions[bot]@users.noreply.github.com
212-
213-
- name: Build message - congratulations
214-
id: build-message-congratulations
215-
uses: skills/action-text-variables@v1
216-
with:
217-
template-file: skills-response-templates/readme/congratulations.md
218-
template-vars: |
219-
login=${{ github.actor }}
220-
221-
- name: Update README - congratulations
222-
run: |
223-
# Add "Congratulations" to the start of the README
224-
orig_readme=$(cat README.md)
225-
new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme"
226-
227-
# Update file and push
228-
echo "$new_readme" > README.md
229-
git add README.md
230-
git commit --message="Congratulations!🎉"
231-
git push
232-
env:
233-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
234-
235-
- name: Build message - exercise finished
236-
id: build-finish-message
237-
uses: skills/action-text-variables@v1
238-
with:
239-
template-file: skills-response-templates/step-feedback/lesson-finished.md
240-
template-vars: |
241-
login=${{ github.actor }}
242-
repo_full_name=${{ github.repository }}
243-
244-
- name: Create comment - exercise finished
245-
run: |
246-
gh issue comment "$ISSUE_URL" \
247-
--body "$ISSUE_BODY"
248-
env:
249-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
250-
ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }}
251-
252-
- name: Close issue
253-
run: gh issue close "$ISSUE_URL"
254-
env:
255-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
256-
257-
- name: Disable current workflow
258-
run: gh workflow disable "${{github.workflow}}"
259-
env:
260-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)