Skip to content

.github/workflows/stats.yml #108

.github/workflows/stats.yml

.github/workflows/stats.yml #108

Workflow file for this run

on:
schedule:
- cron: '50 23 * * *'
jobs:
stats-write:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: baptiste0928/cargo-install@v3
with:
crate: tokei
- uses: actions/checkout@v3
- run: |
TODAY=`date '+%Y-%m-%d'`
YESTERDAY=`date --date '1 day ago' '+%Y-%m-%d'`
# Write data for confirmation
tokei > ./stats/plain/${TODAY}
if [ ! -e ${YESTERDAY} ]; then
tokei --output json > ./stats/json/${TODAY}.json
exit
fi
# Compare with yesterday's
diff -q ./stats/plain/${TODAY} ./stats/plain/${YESTERDAY} > /dev/null 2>&1
if [ $? -eq 1 ]; then
# Write information only when there is a change
tokei --output json > ./stats/json/${TODAY}.json
fi
- uses: stefanzweifel/git-auto-commit-action@v5