48 lines
1.6 KiB
YAML
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 log --all --no-merges --format='%aN' --since="2026-01-01T00:00:00" | grep -iE "patrick|Patrick Beane" | wc -l)
|
|
|
|
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
|