generated from ludeeus/integration_blueprint
-
-
Notifications
You must be signed in to change notification settings - Fork 101
53 lines (43 loc) · 1.7 KB
/
json_librarian.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: JSON Library Sorter and Doc Gen
on:
workflow_dispatch:
push:
paths:
- 'custom_components/battery_notes/data/library.json'
- '.github/workflows/json_librarian.yml'
- '.github/workflows/scripts/library_doc/**'
jobs:
librarian:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Clean up JSON library file
id: update-json
uses: jannekem/run-python-script-action@v1
with:
script: |
import json
# Load the existing JSON library file
with open("custom_components/battery_notes/data/library.json", "r", encoding="UTF-8") as f:
devices_json = json.loads(f.read())
devices = devices_json.get("devices")
# Sort the devices by manufacturer and model
devices.sort(key=lambda k: (k["manufacturer"].lower(), k["model"].lower()))
with open("custom_components/battery_notes/data/library.json", "w", encoding="UTF-8") as f:
f.write(json.dumps(devices_json, indent=4))
- name: Install library doc generator dependencies
run: |
python -m pip install -r ${{ github.workspace }}/.github/scripts/library_doc/requirements.txt
- name: Generate library doc
run: |
python3 ${{ github.workspace }}/.github/scripts/library_doc/generate_file.py
- name: Commit any changes
uses: stefanzweifel/git-auto-commit-action@v5