diff --git a/.github/workflows/tloc.yaml b/.github/workflows/tloc.yaml index 0da1944..098d775 100644 --- a/.github/workflows/tloc.yaml +++ b/.github/workflows/tloc.yaml @@ -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' + LOC: VALUELABELLABELVALUEVALUE + 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