Skip to content

Commit

Permalink
fix config.json validataion
Browse files Browse the repository at this point in the history
  • Loading branch information
Manh Cao committed Sep 24, 2024
1 parent 6d3443d commit 22c9f1d
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions .github/workflows/validate-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: Checkout main branch
run: |
echo "MAIN_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4

- name: Save HEAD commit SHA
run: |
echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
Expand All @@ -34,6 +21,12 @@ jobs:

- name: Validate JSON files
run: |
git diff --name-only $MAIN_SHA $HEAD_SHA | grep -q "^config.json$" && { echo "config.json must not be changed"; exit 1; }
git fetch --all
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

0 comments on commit 22c9f1d

Please sign in to comment.