Files
.profile/.gitea/workflows/update-readme.yaml
2026-01-21 22:05:27 -05:00

48 lines
1.6 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 --filter=blob:none http://gitea-http:3000/${{ github.repository }}.git .
git checkout ${{ github.ref_name }}
- name: Sync with upstream
run: |
git fetch origin
git rebase origin/${{ github.ref_name }}
- name: Process Statistics and Update README
run: |
HUMAN_COUNT=$(git rev-list --count --icase --author="patrick|Patrick Beane" --since="2026-01-01T00:00:00" ${{ github.ref_name }})
echo "COMMIT_VELOCITY=$HUMAN_COUNT" >> $GITHUB_ENV
LOC=$(grep '"total_code"' public/code-stats.json | sed 's/[^0-9]*//g')
FORMATTED_LOC=$(printf "%'d" $LOC)
echo "FORMATTED_LOC=$FORMATTED_LOC" >> $GITHUB_ENV
echo "Injecting $FORMATTED_LOC LOC and $HUMAN_COUNT total human commits..."
sed "s/REPLACE_ME_LOC/$FORMATTED_LOC/g" README.template | \
sed "s/REPLACE_ME_COMMITS/$HUMAN_COUNT/g" > 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 ${{ env.FORMATTED_LOC }} LOC [skip ci]"
git push http://${{ secrets.GITHUB_TOKEN }}@gitea-http:3000/${{ github.repository }}.git ${{ github.ref_name }}
fi