diff --git a/.github/workflows/statistics.yml b/.github/workflows/statistics.yml new file mode 100644 index 00000000..e51aa9f6 --- /dev/null +++ b/.github/workflows/statistics.yml @@ -0,0 +1,40 @@ +name: Statistics Tracker + +on: + push + +permissions: + pages: write + id-token: write + +jobs: + + build: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./stats_tracker + steps: + - name: Checkout the repository to the runner + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate SVG graphic + id: build + run: bash ./generate_svg.sh + - name: Upload static files as artifact + id: deployment + uses: actions/upload-pages-artifact@v3 + with: + path: stats_tracker/build/ + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.gitignore b/.gitignore index d88cd852..f5c63e05 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,7 @@ $RECYCLE.BIN/ ### Gradle ### .gradle /build/ +/stats_tracker/build/ # Ignore Gradle GUI config gradle-app.setting diff --git a/stats_tracker/background.png b/stats_tracker/background.png new file mode 100644 index 00000000..3cc67853 Binary files /dev/null and b/stats_tracker/background.png differ diff --git a/stats_tracker/generate_svg.sh b/stats_tracker/generate_svg.sh new file mode 100644 index 00000000..62272127 --- /dev/null +++ b/stats_tracker/generate_svg.sh @@ -0,0 +1,19 @@ +read f i d <<< $( + git log --shortstat --all | \ + awk '/^ [0-9]/ { f += $1; i += $4; d += $6 } \ + END { printf("%d %d %d", f, i, d) }' +) +echo "File(s) changed: $f" +echo "Insertion(s): $i" +echo "Deletion(s): $d" +value=$(($i - $d)) +echo "Lines of code: $value" +mkdir build +echo " + + + $value +" > build/loc.svg +cp background.png build/background.png \ No newline at end of file