From 578f9ee1464b0cb6036795d49f2c4f9c2690f9ef Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 20 Jan 2026 19:10:11 -0500 Subject: [PATCH] chore: fix README markers and add regex safety checks --- .gitea/workflows/update-readme.yaml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/update-readme.yaml b/.gitea/workflows/update-readme.yaml index f3335d8..6ad758d 100644 --- a/.gitea/workflows/update-readme.yaml +++ b/.gitea/workflows/update-readme.yaml @@ -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 }}