Skip to content

Commit 54bb2a3

Browse files
committed
ci(deploy): deduplicate files and use symlinks
Deduplicate files and attempt to use relative symlinks for deployments. This should dramatically reduce deployment sizes. Signed-off-by: Randolph Sapp <rs@ti.com>
1 parent 1d315ce commit 54bb2a3

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ jobs:
3636
- name: Generate root index
3737
run: ./bin/root_index.py
3838

39+
- name: Deduplicate with rdfind and some help
40+
run: |
41+
apk add rdfind
42+
rdfind -checksum sha256 -makesymlinks true -maxsize 0 \
43+
-followsymlinks true -makeresultsfile false build/
44+
./bin/relink.py build/
45+
3946
- name: Upload static files as single artifact
4047
uses: actions/upload-pages-artifact@v3
4148
with:

bin/relink.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
3+
"""Script to quickly fix symlinks
4+
5+
SPDX-License-Identifier: MIT
6+
Copyright (C) 2025 Texas Instruments Incorporated - https://www.ti.com
7+
"""
8+
9+
import argparse
10+
from pathlib import Path
11+
import logging
12+
13+
logger = logging.getLogger(__name__)
14+
15+
16+
def relink(directory):
17+
"""Relink everything in the given directory to be relative
18+
19+
:param directory: Pathlib path to directory that is to be processed
20+
"""
21+
directory = directory.absolute()
22+
for path in directory.glob("**/*"):
23+
if path.is_symlink():
24+
logger.info("Processing link: %s", path)
25+
26+
real_target = path.resolve()
27+
logger.info("Real target: %s", real_target)
28+
29+
new_target = real_target.relative_to(path.parent, walk_up=True)
30+
logger.info("New target: %s", new_target)
31+
32+
path.unlink()
33+
path.symlink_to(new_target)
34+
35+
36+
def main():
37+
"""Main processing loop"""
38+
logging.basicConfig(level=logging.INFO)
39+
40+
parser = argparse.ArgumentParser(
41+
prog="relink.py", description="Symlink resolver to help rdfind"
42+
)
43+
parser.add_argument("directory", type=Path)
44+
args = parser.parse_args()
45+
46+
relink(args.directory)
47+
48+
49+
if __name__ == "__main__":
50+
main()

0 commit comments

Comments
 (0)