fix config.json validation #88
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: Validate configuration files | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
branches: | |
- 'main' | |
jobs: | |
validate_json_files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' # Or your preferred version | |
- name: Validate JSON files | |
run: | | |
git fetch origin main | |
export HEAD_SHA=$(git rev-parse HEAD) | |
export MAIN_SHA=$(git rev-parse origin/main) | |
echo $HEAD_SHA | |
echo $MAIN_SHA | |
echo $(git merge-base $MAIN_SHA $HEAD_SHA) | |
git diff --quiet $(git merge-base $MAIN_SHA $HEAD_SHA) $HEAD_SHA -- config.json || (echo "config.json must not be changed" && exit 1) | |
CHANGED_PROTOCOLS=$(git diff --name-only $MAIN_SHA $HEAD_SHA -- 'protocols/*' | grep '^protocols/' | xargs -L1 dirname | sed 's|protocols/||' | sort -u) | |
CHANGED_PROTOCOLS=$CHANGED_PROTOCOLS node validate-config.js |