Skip to content

Commit e072fc1

Browse files
committed
Add a step to sort the JSON
(only on workflow_dispatch or when pushing to main)
1 parent 02b2e1a commit e072fc1

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

.github/workflows/CI_build.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@ jobs:
5050
# since AC may have been added to JSON, need to revalidate JSON and re-generate md
5151
python .validators\validator_json.py --output-md
5252
53+
- name: ⇅ Sort JSON
54+
working-directory: .
55+
if: ${{ contains('push workflow_dispatch', github.event_name) && github.ref == 'refs/heads/master' && github.repository == 'notepad-plus-plus/userDefinedLanguages' }}
56+
run: |
57+
# sort JSON back into string
58+
$file = "udl-list.json"
59+
$a = Get-Content $file | ConvertFrom-Json
60+
$a.'UDLs' = $a.'UDLs' | sort -Property 'id-name'
61+
$content = $a | ConvertTo-Json -Depth 5
62+
#
63+
# reformat JSON
64+
$content = $content -replace ': ', ": "
65+
$content = $content -replace ' ', " "
66+
$content = $content -replace ' ', " "
67+
$content = $content -replace ' ', " "
68+
#
69+
# save sorted JSON text
70+
$content > $file
71+
5372
- name: 🎉 Update repo with automated changes for the UDL list and autoCompletions
5473
uses: stefanzweifel/git-auto-commit-action@v7
5574
if: contains('push workflow_dispatch', github.event_name)

0 commit comments

Comments
 (0)