Skip to content

Update related_website_sets.JSON #103

Update related_website_sets.JSON

Update related_website_sets.JSON #103

Workflow file for this run

# 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:
PR-Metadata-Actions:
runs-on: ubuntu-24.04
steps:
- name: Check title/body of PR for bailout phrases
uses: actions/github-script@v7
env:
TITLE: ${{ github.event.pull_request.title }}
BODY: ${{ github.event.pull_request.bodyText }}
with:
script: |
const pattern = /Not\s+a\s+Contribution/i;
const { BODY, TITLE } = process.env;
if (pattern.test(BODY) || pattern.test(TITLE)) {
const message = "This PR is marked 'Not a Contribution'; DO NOT COMMIT.";
core.setFailed(message);
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message,
});
}
JSON-Actions:
runs-on: ubuntu-24.04
needs: PR-Metadata-Actions
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@babb053761401147562e75be79d832978cc97325
with:
path: "results.txt"
- name: Read the Changed Files
id: read_files
uses: tj-actions/changed-files@a284dc1814e3fd07f2e34267fc8f81227ed29fb8
- 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@b8f338c590a895d50bcbfa6c5859251edc8952fc
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.')