update: change GitHub Actions workflow to use Python
This commit is contained in:
@@ -18,15 +18,24 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
LOC=$(grep '"total_code"' public/code-stats.json | sed 's/[^0-9]*//g')
|
LOC=$(grep '"total_code"' public/code-stats.json | sed 's/[^0-9]*//g')
|
||||||
FORMATTED_LOC=$(printf "%'d" $LOC)
|
FORMATTED_LOC=$(printf "%'d" $LOC)
|
||||||
|
echo "Syncing $FORMATTED_LOC lines..."
|
||||||
if ! grep -q "" README.md; then
|
|
||||||
echo "ERROR: Could not find markers in README.md. Aborting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Detected $FORMATTED_LOC lines. Updating anchored markers..."
|
python3 -c "
|
||||||
|
import os
|
||||||
sed -i "s/.*/$FORMATTED_LOC/" README.md
|
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
|
- name: Commit and Push
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user