diff --git a/.github/workflows/validate-config.yml b/.github/workflows/validate-config.yml index 6c75f97..af71196 100644 --- a/.github/workflows/validate-config.yml +++ b/.github/workflows/validate-config.yml @@ -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 @@ -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 \ No newline at end of file