Skip to content

FEAT: Adding the Lines of Code Badge WorkFlow File #1

FEAT: Adding the Lines of Code Badge WorkFlow File

FEAT: Adding the Lines of Code Badge WorkFlow File #1

Workflow file for this run

name: Generate LoC Badge
permissions:
contents: write
on:
push:
branches: [ main ]
workflow_dispatch: {}
jobs:
generate:
name: Generate Lines-of-Code Badge
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: true
- name: Make Code Badge
uses: shadowmoose/[email protected]
id: badge
with:
debug: true
directory: ./
badge: ./output/badge.svg
patterns: "**/*.py|**/*.sh|Makefile"
ignore: ".venv|venv|env|node_modules|.git"
- name: Push badge to image-data branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Prepare a minimal repo containing only the badge and push it to image-data
mkdir -p badge-tmp
cp output/badge.svg badge-tmp/badge.svg
cd badge-tmp
# Initialize with main as default branch and set local identity
git init -b main
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Ensure commit has explicit author/committer env vars to avoid empty ident
GIT_AUTHOR_NAME="github-actions[bot]" GIT_AUTHOR_EMAIL="41898282+github-actions[bot]@users.noreply.github.com" GIT_COMMITTER_NAME="github-actions[bot]" GIT_COMMITTER_EMAIL="41898282+github-actions[bot]@users.noreply.github.com" git add badge.svg && \
GIT_AUTHOR_NAME="github-actions[bot]" GIT_AUTHOR_EMAIL="41898282+github-actions[bot]@users.noreply.github.com" GIT_COMMITTER_NAME="github-actions[bot]" GIT_COMMITTER_EMAIL="41898282+github-actions[bot]@users.noreply.github.com" git commit -m "chore: update LoC badge"
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
git push --force origin HEAD:image-data