-
Notifications
You must be signed in to change notification settings - Fork 612
67 lines (67 loc) · 2.47 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: JSON Validations
on: pull_request_target
permissions:
pull-requests: write
jobs:
JSON-Actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get the PR JSON
uses: actions/checkout@v4
with:
ref: "refs/pull/${{ github.event.number }}/merge"
path: "pull-request"
sparse-checkout: "related_website_sets.JSON"
- uses: actions/setup-python@v5
with:
check-latest: true
- name: Validate JSON
run: |
pip3 install -r requirements.txt
python3 check_sites.py -i pull-request/related_website_sets.JSON --with_diff --strict_formatting > results.txt
- name: Read the Validation Results
id: read_results
uses: andstor/file-reader-action@v1
with:
path: "results.txt"
- name: Read the Changed Files
id: read_files
uses: tj-actions/changed-files@v45
- name: Failure Comment
if: steps.read_results.outputs.contents != 'success'
run: |
echo "The RWS JSON was not successfully validated. Here are your results:" > message.txt
cat results.txt >> message.txt
- name: Success Comment
if: steps.read_results.outputs.contents == 'success'
run: echo "The RWS JSON was successfully validated!" > message.txt
- name: System Comment
if: steps.read_files.outputs.all_changed_and_modified_files != 'related_website_sets.JSON'
run: |
echo "<br/>***THIS PR CONTAINS SYSTEM CHANGES PLEASE REVIEW WITH CARE!***" >> message.txt
- name: Write Comment
uses: mshick/add-pr-comment@v2
with:
message-path: "message.txt"
refresh-message-position: true
- name: Write Summary
run: cat message.txt >> $GITHUB_STEP_SUMMARY
- name: Record Failure
if: steps.read_results.outputs.contents != 'success'
uses: actions/github-script@v3
with:
script: core.setFailed('This run has failed.')