diff --git a/.github/workflows/sort-data.yml b/.github/workflows/sort-data.yml new file mode 100644 index 00000000..8823f505 --- /dev/null +++ b/.github/workflows/sort-data.yml @@ -0,0 +1,49 @@ +name: Sort data files + +on: + push: + branches: + - main + paths: + - "assets/data/**" + + pull_request: + paths: + - "assets/data/**" + + workflow_dispatch: + +jobs: + sort-data: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Get changed data files + id: changed-data + uses: tj-actions/changed-files@v45 + with: + files: assets/data/**.{json} + + - name: Sort data files + if: steps.changed-data.outputs.any_changed == 'true' + uses: actions/setup-python@v5 + with: + python-version: '3.12' + env: + ALL_CHANGED_FILES: ${{ steps.changed-data.outputs.all_changed_files }} + run: | + for file in $ALL_CHANGED_FILES; do + python3 format_data.py -f $file + done + + # commit all changed files back to the repository + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Sort data files diff --git a/assets/img/diciotech-screenshot.png b/assets/img/diciotech-screenshot.png index 7bdf4beb..602650f9 100644 Binary files a/assets/img/diciotech-screenshot.png and b/assets/img/diciotech-screenshot.png differ diff --git a/format_data.py b/format_data.py index ae0b4c0c..0cdcfa20 100644 --- a/format_data.py +++ b/format_data.py @@ -19,6 +19,10 @@ def main(file: Path): for card in data['cards']: card['tags'] = sorted(card['tags'], key=lambda x: strip_accents(x.lower())) + # ensures that the description ends with a period + if not card['description'].endswith('.'): + card['description'] += '.' + # sort keys in the cards by reverse key order data['cards'] = [{k: v for k, v in sorted(card.items(), reverse=True)} for card in data['cards']]