chore: fix README markers and add regex safety checks
This commit is contained in:
@@ -17,27 +17,24 @@ jobs:
|
||||
- name: Update README
|
||||
run: |
|
||||
LOC=$(grep '"total_code"' public/code-stats.json | sed 's/[^0-9]*//g')
|
||||
FORMATTED_LOC=$(printf "%'d" $LOC)
|
||||
|
||||
if [ -z "$LOC" ] || [ "$LOC" -eq 0 ]; then
|
||||
echo "Error: Could not parse LOC or LOC is 0. Checking file existence..."
|
||||
ls -R public/
|
||||
if ! grep -q "" README.md; then
|
||||
echo "ERROR: Could not find markers in README.md. Aborting to prevent runaway."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FORMATTED_LOC=$(printf "%'d" $LOC)
|
||||
echo "Detected $FORMATTED_LOC lines of code. Updating README..."
|
||||
echo "Detected $FORMATTED_LOC lines. Updating anchored markers..."
|
||||
|
||||
sed -i "s/\(\).*\(\)/\1$FORMATTED_LOC\2/" README.md
|
||||
sed -i "s/.*/$FORMATTED_LOC/" README.md
|
||||
|
||||
- name: Commit and Push
|
||||
run: |
|
||||
git config user.name "Ares-Bot"
|
||||
git config user.email "ares@beane.me"
|
||||
git add README.md
|
||||
|
||||
if git diff --staged --quiet; then
|
||||
echo "No changes"
|
||||
else
|
||||
git commit -m "chore: sync code velocity to $FORMATTED_LOC LOC [skip ci]"
|
||||
git push http://${{ secrets.GITHUB_TOKEN }}@gitea-http:3000/${{ github.repository }}.git main
|
||||
fi
|
||||
git push http://${{ secrets.GITHUB_TOKEN }}@gitea-http:3000/${{ github.repository }}.git ${{ github.ref_name }}
|
||||
|
||||
Reference in New Issue
Block a user