update: change GitHub Actions workflow to use Python

This commit is contained in:
2026-01-20 19:21:12 -05:00
parent 54ec6594ca
commit 51703d45f8

View File

@@ -18,15 +18,24 @@ jobs:
run: |
LOC=$(grep '"total_code"' public/code-stats.json | sed 's/[^0-9]*//g')
FORMATTED_LOC=$(printf "%'d" $LOC)
if ! grep -q "" README.md; then
echo "ERROR: Could not find markers in README.md. Aborting."
exit 1
fi
echo "Syncing $FORMATTED_LOC lines..."
echo "Detected $FORMATTED_LOC lines. Updating anchored markers..."
sed -i "s/.*/$FORMATTED_LOC/" README.md
python3 -c "
import os
content = open('README.md').read()
marker_start = ''
marker_end = ''
if marker_start in content and marker_end in content:
before = content.split(marker_start)[0]
after = content.split(marker_end)[1]
new_content = before + marker_start + '$FORMATTED_LOC' + marker_end + after
with open('README.md', 'w') as f:
f.write(new_content)
print('Successfully updated README.')
else:
print('Markers not found!')
exit(1)
"
- name: Commit and Push
run: |