-
Notifications
You must be signed in to change notification settings - Fork 6
78 lines (67 loc) · 2.36 KB
/
validate.yml
File metadata and controls
78 lines (67 loc) · 2.36 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
name: Validate Submission
on:
pull_request:
paths:
- 'agents/**'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Detect changed agent folders
id: changed
run: |
FOLDERS=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..HEAD -- agents/ \
| cut -d'/' -f1-2 \
| sort -u \
| tr '\n' ' ')
echo "folders=$FOLDERS" >> "$GITHUB_OUTPUT"
echo "Changed folders: $FOLDERS"
- name: Validate submissions
id: validate
run: |
RESULT=0
for folder in ${{ steps.changed.outputs.folders }}; do
echo "::group::Validating $folder"
npx tsx scripts/validate.ts "$folder" || RESULT=1
echo "::endgroup::"
done
exit $RESULT
- name: Comment on PR
if: always()
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('## Registry Validation')
);
const status = '${{ steps.validate.outcome }}' === 'success' ? '✓ Passed' : '✗ Failed';
const emoji = '${{ steps.validate.outcome }}' === 'success' ? '✅' : '❌';
const body = `## Registry Validation ${emoji}\n\n**Status:** ${status}\n\nChanged folders: \`${{ steps.changed.outputs.folders }}\`\n\n---\n*Validated by CI*`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}