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