-
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (61 loc) · 2.11 KB
/
format.yaml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: autofix.ci
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
autofix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PNPM
uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Dependencies
run: pnpm i
- name: Run prettier
run: pnpm exec prettier . --write
# Optimize all PNGs with https://pngquant.org/
- run: sudo apt-get update && sudo apt-get install -y pngquant
- name: Run pngquant
run: |
shopt -s globstar
find . -name '*.png' -exec pngquant --ext .png --force 256 {} \;
- name: Sort Files
run: |
import json
def sort_files_by_target_path(files):
def sort_key(file_obj):
target_path = file_obj.get("targetPath", "").lower()
segments = target_path.split('/')
key = []
for idx, segment in enumerate(segments):
# A file is the final segment with no further sub-paths
is_file = idx == len(segments) - 1 and '.' in segment
key.append((segment, is_file))
return key
return sorted(files, key=sort_key)
input_file = "repos.json"
with open(input_file, "r") as f:
data = json.load(f)
if "repositories" not in data:
print(f"Error: {input_file} does not contain a 'repositories' key.")
exit(1)
for repo in data["repositories"]:
if "files" in repo:
repo["files"] = sort_files_by_target_path(repo["files"])
with open(input_file, "w") as f:
json.dump(data, f, indent=2)
f.write("\n")
shell: python
- uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c