Add example readme #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Schemas Structure | |
on: | |
pull_request: | |
jobs: | |
check-structure: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Check for required files | |
run: | | |
missing_files=0 | |
for entity in schemas/*; do | |
if [ -d "$entity" ]; then | |
if [ ! -f "$entity/README.md" ]; then | |
echo "Missing README.md in $entity" | |
missing_files=1 | |
fi | |
if [ ! -f "$entity/CODEOWNERS" ]; then | |
echo "Missing CODEOWNERS in $entity" | |
missing_files=1 | |
fi | |
fi | |
done | |
exit $missing_files | |
- name: Check no changes to schemas | |
run: | | |
invalid_changes=0 | |
changes="" | |
echo "Checking for changes in schema files..." | |
# Fetch the base branch to compare | |
git fetch origin ${{ github.event.pull_request.base.ref }} | |
# Get the list of changed files in the PR within 'schemas/**/*' | |
changed_files=$(git diff --name-only --diff-filter=M origin/${{ github.event.pull_request.base.ref }}...HEAD -- 'schemas/**/*') | |
echo "Changed files: $changed_files" | |
for file in $changed_files; do | |
if [ -f "$file" ] && [ "$(basename "$file")" != "README.md" ] && [ "$(basename "$file")" != "CODEOWNERS" ]; then | |
echo "Change detected in $file..." | |
changes="$changes\nUnexpected change in $file" | |
invalid_changes=1 | |
fi | |
done | |
echo "changes<<EOF" >> $GITHUB_ENV | |
echo -e "$changes" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Comment on PR if there are unexpected changes | |
if: env.changes != '' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.pulls.createReview({ | |
pull_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Unexpected changes detected, you should not update a schema file, consider creating a new version instead:\n${{ env.changes }}`, | |
event: 'REQUEST_CHANGES' | |
}) |