macoaure/badge-action

Generate dynamic badges using shields.io API

v1.0.0 2025-04-28 01:07 UTC

This package is auto-updated.

Last update: 2025-04-28 02:18:21 UTC


README

Build Status Version License Code Coverage

A GitHub Action for generating dynamic SVG badges using Shields.io. Create and update beautiful, customizable badges directly in your GitHub repository.

🌟 Features

  • 🎨 Fully Customizable: Colors, styles, logos, and more
  • 🔄 Dynamic Updates: Automatically update badges on repository changes
  • 🎯 Multiple Badge Styles: Support for flat, flat-square, plastic, for-the-badge, and social styles
  • 🔒 Cache Control: Configure badge caching for optimal performance
  • 🔗 Clickable Badges: Add links to make badges interactive
  • 🛡️ Powered by Shields.io: Built on the reliable Shields.io API

📋 Quick Start

  1. Create a badges directory in your repository:
mkdir -p badges
  1. Add this to your GitHub workflow:
- name: Generate Badge
  uses: macoaure/badge-action@v1
  with:
    label: "build"
    status: "passing"
    path: "badges/build.svg"
    color: "green"
    style: "flat-square"
  1. Reference your badge in your README:
[![Build Status](https://raw.githubusercontent.com/USER/REPO/BRANCH/badges/build.svg)](https://github.com/USER/REPO/actions)

🎯 Use Cases

Build Status Badge

- name: Generate Build Badge
  uses: macoaure/badge-action@v1
  with:
    label: "build"
    status: "passing"
    path: "badges/build.svg"
    color: "green"
    logo: "github"

Version Badge

- name: Generate Version Badge
  uses: macoaure/badge-action@v1
  with:
    label: "version"
    status: ${{ github.ref_name }}
    path: "badges/version.svg"
    color: "blue"
    style: "flat-square"

Coverage Badge

- name: Generate Coverage Badge
  uses: macoaure/badge-action@v1
  with:
    label: "coverage"
    status: "95%"
    path: "badges/coverage.svg"
    color: "brightgreen"
    logo: "codecov"

📝 Inputs

Input Description Required Default
label Left side text Yes -
status Right side text Yes -
path Output file path Yes -
color Badge color No blue
label-color Left side color No 555
style Badge style No flat-square
logo Logo from simple-icons.org No -
logo-color Logo color No -
cache-seconds Cache duration No -
link Clickable URL No -
max-age Maximum cache age No -

🎨 Available Styles

  • flat - Flat style
  • flat-square - Flat square style
  • plastic - 3D plastic style
  • for-the-badge - Bold, wider style
  • social - Social media style

🔄 Complete Workflow Example

name: Generate Badges

on:
  push:
    branches: [main]

jobs:
  generate-badges:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # Optional: Calculate coverage if needed
      - name: Calculate coverage
        id: coverage
        run: |
          # Your coverage calculation here
          echo "coverage=95%" >> $GITHUB_OUTPUT

      - name: Generate Build Badge
        uses: macoaure/badge-action@v1
        with:
          label: "build"
          status: "passing"
          path: "badges/build.svg"
          color: "green"
          style: "flat-square"
          logo: "github"

      - name: Generate Coverage Badge
        uses: macoaure/badge-action@v1
        with:
          label: "coverage"
          status: ${{ steps.coverage.outputs.coverage }}
          path: "badges/coverage.svg"
          color: "brightgreen"
          logo: "codecov"

      # Commit and push the badges
      - name: Commit changes
        run: |
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          git add badges/
          git commit -m "🔄 Update repository badges"
          git push

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Credits

🔍 Related