41 lines
1.2 KiB
YAML
41 lines
1.2 KiB
YAML
name: Update Code Statistics
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'public/code-stats.json'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
sync-stats:
|
|
runs-on: sh
|
|
steps:
|
|
- name: Manual Internal Checkout
|
|
run: |
|
|
git clone http://gitea-http:3000/${{ github.repository }}.git .
|
|
git checkout ${{ github.ref_name }}
|
|
|
|
- name: Update README
|
|
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 to prevent runaway."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Detected $FORMATTED_LOC lines. Updating anchored markers..."
|
|
|
|
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 ${{ github.ref_name }}
|