Skip to content
Open
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
25 changes: 22 additions & 3 deletions .github/workflows/tloc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- name: Code Lines Badge
uses: Kherrisan/cloc-badge-action@1.0.1
- uses: actions/checkout@v4
- name: Count Lines of Code
run: |
sudo apt-get update -qq && sudo apt-get install -y cloc
cloc . --quiet --json --out=cloc.json
LOC=$(cat cloc.json | python3 -c "import json,sys; d=json.load(sys.stdin); print(sum(d[k]['code'] for k in d if k!='header'))")
echo "LOC=$LOC" >> $GITHUB_ENV
echo "LOC" > label.txt
echo "$LOC" > value.txt
- name: Create badge
run: |
LABEL=$(cat label.txt)
VALUE=$(cat value.txt)
cat > cloc.svg << 'EOF'
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="92" height="20" role="img" aria-label="LOC: VALUE"><title>LOC: VALUE</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="92" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="35" height="20" fill="#555"/><rect x="35" width="57" height="20" fill="#007ec6"/><rect width="92" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text x="185" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="280">LABEL</text><text x="185" y="140" transform="scale(.1)" textLength="280">LABEL</text><text x="635" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">VALUE</text><text x="635" y="140" transform="scale(.1)" textLength="510">VALUE</text></g></svg>
EOF
sed -i "s/LABEL/$LABEL/g; s/VALUE/$VALUE/g" cloc.svg
- name: Commit badge
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update LOC badge"
file_pattern: cloc.svg