Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

68 add GitHub statistics tracking #69

Merged
merged 8 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/statistics.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ $RECYCLE.BIN/
### Gradle ###
.gradle
/build/
/stats_tracker/build/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
Binary file added stats_tracker/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions stats_tracker/generate_svg.sh
Original file line number Diff line number Diff line change
@@ -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 "<svg width=\"300px\" height=\"300px\" xmlns=\"http://www.w3.org/2000/svg\">
<style>
@import url(\"https://fonts.googleapis.com/css?family=Source+Code+Pro\");
</style>
<image href=\"background.png\" width=\"100%\"/>
<text x=\"50%\" y=\"90px\" font-size=\"65\" text-anchor=\"middle\" fill=\"black\" font-family=\"Source Code Pro\" font-weight=\"bold\">$value</text>
</svg>" > build/loc.svg
cp background.png build/background.png
Loading