-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (96 loc) · 3.71 KB
/
4b-copilot-on-github.yml
File metadata and controls
112 lines (96 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Step 4b # Copilot on GitHub
on:
# Trigger if PR Description is edited
# Disabled because PR summaries are not available for free accounts
# pull_request:
# branches:
# - main
# types:
# - edited
# Trigger if Copilot adds a review comment
pull_request_review:
permissions:
contents: write
actions: write
issues: write
pull-requests: read
repository-projects: read
jobs:
find_exercise:
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.6.0
check_step_work:
name: Check step work
runs-on: ubuntu-latest
needs: [find_exercise]
env:
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get response templates
uses: actions/checkout@v4
with:
repository: skills/exercise-toolkit
path: exercise-toolkit
ref: v0.6.0
# START: Check practical exercise
- name: Check for PR description
continue-on-error: true
id: check-pr-description
run: |
# Check if PR has a description and minimum length
min_length=15
body_length=$(echo "$PR_Body" | wc -c)
echo "PR description length: $body_length"
if [ "$body_length" -lt $min_length ]; then
echo "::error::PR description is too short or missing"
exit 1
fi
env:
PR_Body: ${{ github.event.pull_request.body }}
- name: Check for Copilot review
id: check-copilot-review
run: |
# Check for a PR Review from Copilot
reviews=$(gh pr view --repo $REPO $PR_NUMBER --json reviews)
authors=$(echo "$reviews" | jq '.reviews[].author.login')
if echo "$authors" | grep -q "copilot-pull-request-reviewer"; then
echo "Copilot has reviewed this PR."
else
echo "Copilot has NOT reviewed this PR."
echo "::error::No review from Copilot found"
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
continue-on-error: true
- name: Build message - step results
id: build-message-step-results
uses: skills/action-text-variables@v2
with:
template-file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md
template-vars: |
step_number: 4
passed: ${{ !contains(steps.*.outcome, 'failure') }}
results_table:
- description: "Pull request contains a descriptive overview"
passed: ${{ steps.check-pr-description.outcome == 'success' }}
- description: "Pull request received a review from GitHub Copilot"
passed: ${{ steps.check-copilot-review.outcome == 'success' }}
tips:
- "If you already requested Copilot review and this check did not pass, go to your repository [actions](https://github.com/${{github.repository}}/actions) tab to check if a workflow run is awaiting your manual approval."
- "You can use repository rulesets to automatically require a review from Copilot."
- name: Create comment - step results
run: |
gh issue comment "$ISSUE_URL" \
--body "$COMMENT_BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }}
- name: Fail job if not all checks passed
if: contains(steps.*.outcome, 'failure')
run: exit 1
# END: Check practical exercise