Skip to content

Badgetizr is a tool to allow custom badges automatically added and updated according the content of your pull request.

License

Notifications You must be signed in to change notification settings

aiKrice/homebrew-badgetizr

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Badgetizr

Static Badge Static Badge Static Badge Static Badge

Add badges to your pull requests and increase your productivity 🚀.


What is Badgetizr ?

Badgetizr is a tool that will add badges to your pull requests to increase your team's productivity. It is fully customizable and you can add (almost) as many badges as you want. With Badgtizr on your CI, you will be able to save time by:

  • Stop adding a link to your ticket in the description of the PR if you add the id of it in the title of the PR.
  • Reminding that some tasks are still missing to do in the PR.
  • Stop adding a visual indicator if your PR is a WIP.
  • Having a badge to know the status of the CI pipeline without having to click on it, scrolling down to the bottom of the page (coming soon).

To read before going further: I need your ⭐ !

📣 I would like to put this tool available with Homebrew and Apt-Get. To succeed, I need a maximum of star on this repository (according to the submission of Homebrew, min = 75stars). By using Homebrew or apt-get, I will be able to simplify the installation process by skipping the configure step below 🚀. Thank you for your help!

Roadmap

  • Add option to use a custom configuration file
  • Make the badge_ci badge dynamic (success, failure, pending)
  • Add a beautiful icon for this repository
  • Improve the Readme.md file
  • Add the tools to Homebrew tap
  • Add the tool to Homebrew
  • Add the tool to Apt-Get
  • Add the tools to Github Actions
  • Support natively Gitlab with glab CLI

To see how to contribute, please refer to the section Contributing.

I love coffee ☕.

If your productivity has increased, my mission is done 🎉. This means I can go back to my coffee and enjoy it 🤤. If you want to support me, you can buy me a coffee, you will be mentioned in the README.md file as a backer ❤️. It will also motivate me to continue to work on this tool and improve it. Buy Me a Coffee at ko-fi.com

Installation via Homebrew (MacOS)

For now, only Github Pull Requests are supported. You have to export the environment variables GITHUB_TOKEN such as:

export GITHUB_TOKEN="your_github_token"

Then you can run the configure script and the badgetizer script:

$ brew tap aiKrice/badgetizr
$ brew install aiKrice/badgetizr/badgetizr
# edit the .badgetizr.yml file to your needs
$ export GITHUB_TOKEN="your_github_token"

Installation via Apt-Get (Linux)

Coming soon...

Installation manually (for MacOS and Linux)

$ git clone https://github.com/aiKrice/badgetizr.git --branch master
$ cd badgetizr
$ ./configure

In the rest of the documentation, I will consider that you have installed the tool in your $PATH and remove the .sh extension from the binary name.

Usage (CLI)

$ badgetizr #[options]

To see the different options available, you can use the --help option:

$ badgetizr --help

Usage GithubAction

Instead of using the CLI, you can directly use the github action in your workflow.

jobs:
  badgetizr:
    runs-on: ubuntu-latest #works also on macos-latest

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v3

      - name: Run Badgetizr
        uses: aiKrice/[email protected]
        with:
          pr_id: ${{ github.event.pull_request.number }}
          configuration: .badgetizr.yml
          pr_destination_branch: ${{ github.event.pull_request.base.ref }}
          pr_build_number: ${{ github.run_id }}
          pr_build_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Configuration

By default, the configuration file used is .badgetizr.yml. You can also specify a configuration file to use by using the -c option.

$ badgetizer -c my_config.yml

You can look to the .badgetizr.yml.example file at the root of the repository to see the different configuration options available.

If you want to use an icon for your badge, you can use the icon option and specify the icon name (badge ci only). All icons are available at simpleicons.org.

Badges

Badge Ticket Static Badge

Status

Disabled by default.

Description

The badge ticket is a badge that will be displayed on your pull request if you have a Jira ticket or a Youtrack ticket in your pull request title or overall, something you would like to extract from the pull request title. To do so, you have to define a pattern that will be used to extract the data (ie: ticket id). This pattern will be used with the sed command with the -n -E options and the p flag and will extract the first occurrence of the pattern found in the string. Badgetizr will process the pattern like this: sed -n -E "s/${ticket_badge_pattern}/\1/p"'. You have to provide a regex group with ()

Configuration:

  • color: The color of the badge (default: blue).
  • label: The label of the badge (default: JIRA).
  • logo: The logo of the badge (default: jirasoftware).
  • sed_pattern: The pattern to use to extract the ticket id from the pull request title (default: .*\(([^)]+)\).*, will match something like feat(ABC-123): My Pull Request Title -> ABC-123).
  • url: The url of the badge (default: https://yourproject.atlassian.net/browse/%s, will be https://yourproject.atlassian.net/browse/ABC-123). You don't need to escape the - and characters, they will be automatically escaped.

Badge Wip Static Badge

Status

Enabled by default.

Description

The badge wip is a badge that will be displayed on your pull request if the pull request title contains the word WIP whatever the case.

Badge Dynamic Static Badge

Status

Disabled by default.

Description

The badge dynamic is a badge that will be displayed on your pull request if the pull request body contains a pattern. You can define multiple patterns and each pattern will be displayed with a badge.

Configuration:

  • color: The color of the badge (default: grey).
  • label: The label of the badge (default: Task 2).
  • value: The value of the badge (default: Done).
  • sed_pattern: The pattern which will be applied against the pull request body (default: no pattern). A regex group () must be present or it will trigger a sed error. See .badgetizr.yml.example file.

example:

- sed_pattern: "(- [ ] Task 1)"
  label: "Task 1"
  value: "Not done"
  color: "orange"

will display: Static Badge if the checkbox is not checked.

In this case you can also use this to display a badge if the checkbox is checked. example:

- sed_pattern: "(- [x] Task 2)"
  label: "Task 2"
  value: "Done"
  color: "green"

will display: Static Badge if the checkbox is checked.

You don't need to escape the - and characters, they will be automatically escaped.

⚠️ Beware currently the regex has limitations, it is not using sed regex but only bash regex by checking if the pattern is found in the string (like a contains). An opened issue has been created and you are welcome to contribute to fix this ❤️.

Badge Base Branch Static Badge

Status

Enabled by default.

Description

The badge base branch is a badge that will be displayed on your pull request to indicate the target branch of the pull request. The default value is develop.

CLI Parameters

  • --pr-destination-branch: The base branch to use to compare the pull request to.

Badge CI Static Badge

Status

Disabled by default.

Description

The badge ci is a badge that will be displayed on your pull request to indicate the status of the CI pipeline, the build number and the build url. Currently the status is static but it will be dynamic in a short future.

CLI Parameters:

  • --pr-build-number: The build number of the CI pipeline.
  • --pr-build-url: The build url of the CI pipeline.

Configuration:

  • color: The color of the badge (default: purple).
  • label: The label of the badge (default: Bitrise).
  • logo: The logo of the badge (default: bitrise).

Example

badge_ticket:
  enabled: "true"
  settings:
    color: "black"
    label: "Github"
    sed_pattern: '.*\[GH-([0-9]+)\].*'
    url: "https://github.com/aiKrice/badgetizr/issues/%s"
    logo: "github"

will match feat(scope): implement stuff [GH-1234] #will extract 1234

Contributing

You are welcome to contribute to this project. The current rules to follow is that each time you are opening a pull request, you have to generate yourself the badge inside the pull request by running the script locally on your machine when your forked the repository.

example:

export GITHUB_TOKEN="your_github_token"
$ ./configure #optional, just for dependencies
$ ./badgetizer.sh

Publishing (for maintainers)

To publish the tool, you can run the publish.sh script by providing the version you want to release. Please respect the semantic versioning notation.

./publish.sh 1.1.3

This script will bump everything possible to keep everything up-to-date.

About

Badgetizr is a tool to allow custom badges automatically added and updated according the content of your pull request.

Topics

Resources

License

Stars

Watchers

Forks