Skip to content

Commit

Permalink
Merge branch 'main' into prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
levxyca authored Nov 5, 2024
2 parents 974f0a0 + 2474f41 commit 6bd9130
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/sort-data.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file modified assets/img/diciotech-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions format_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']]

Expand Down

0 comments on commit 6bd9130

Please sign in to comment.