From fe5aa802855301c277d25d4d019d61828039899c Mon Sep 17 00:00:00 2001 From: Peter Law Date: Sat, 3 Aug 2024 10:25:33 +0100 Subject: [PATCH] Normalise the JSON redirects file before diffing This ensures that key-ordering changes, which don't affect the semantics of the file, don't create diff noise. --- .github/workflows/publish.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1e64bf54..acef70e3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -115,6 +115,28 @@ jobs: name: build-from-main path: main + - name: Normalise JSON + shell: python + run: | + import json + from pathlib import Path + + ROOTS = [ + Path('main/_site'), + Path('local/_site'), + ] + FILES = [ + 'redirects.json', + ] + + for root in ROOTS: + for name in FILES: + p = root / name + p.write_text(json.dumps( + json.loads(p.read_text()), + sort_keys=True, + )) + - name: Diff id: diff run: |