.github/workflows/stats.yml #115
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |