forked from OWASP/www-community
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (53 loc) · 1.82 KB
/
validate-tools-json.yml
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
name: Validate Tools JSON
on:
pull_request_target:
paths:
- '_data/tools.json'
jobs:
schema-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 13.x
- name: Install dependencies
run: |
npm install -g ajv-formats
npm install -g ajv-cli
- name: Run schema check
run: |
ajv validate -s tools_schema.json -d _data/tools.json --all-errors --errors=text --verbose=true -c=ajv-formats 1> log.txt 2>&1
- name: Show Validation Issues
id: validation
if: failure()
run: |
cat log.txt
ISSUES=$(cat log.txt)
ISSUES="${ISSUES//'%'/'%25'}"
ISSUES="${ISSUES//$'\n'/'%0A'}"
ISSUES="${ISSUES//$'\r'/'%0D'}"
echo ::set-output name=ISSUES::$ISSUES
- name: Attach Log
uses: actions/upload-artifact@v2
if: failure()
with:
name: JSONValidationLog
path: log.txt
- name: Comment Validation Issues
if: failure()
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: ${{ github.event.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: `**The following issues were identified, when validatoin against the [schema](https://github.com/OWASP/www-community/blob/master/tools_schema.json):**\n\n<details><summary>Summary (click the triangle/control to the left to expand)</summary>\n\n\`\`\`\n${{ steps.validation.outputs.ISSUES }}\n\`\`\`\n\n</details>`
})