Skip to content

Commit

Permalink
Add configuration file parameter (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
aiKrice authored Nov 26, 2024
1 parent 20fd6ef commit e8cab95
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 5 deletions.
15 changes: 15 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: [aiKrice]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: awesome_ios_android
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
thanks_dev: gh/aikrice
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<h1 align="center">
Badgetizr
</h1>
<h2 align="center">
Add badges to your pull requests and increase your productivity 🚀.
</h2>

<div id="header" align="center">
<img src="badgetizr_screen.png" width="1000"/>
Expand All @@ -10,17 +13,46 @@
---

## To read before going further: I need your ⭐ !
I would like to put this tool available with Homebrew and Apt-Get. Tu succeed, I need a maximum of star on this repository (according to the submission of Homebrew, min = 40stars). 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!
_📣 I would like to put this tool available with Homebrew and Apt-Get. Tu succeed, I need a maximum of star on this repository (according to the submission of Homebrew, min = 40stars). 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
- [x] 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 tool to Homebrew
- [ ] Add the tool to Apt-Get
- [ ] Add the tools to Github Actions
- [ ] Add the tools to Github Marketplace
- [ ] Support natively Gitlab with `glab` CLI

To see how to contribute, please refer to the section [Contributing](#contributing).

## I am 🇫🇷 and I love coffee ☕.
I am fully engaged to make this tool the best tool ever to add badges to your pull requests and increase your productivity 🚀. The roadmap is huge and I will do my best to achieve all of this and achieve my goal to make this the best tool to add badges to your pull requests. If you want to support me, you can buy me a coffee, you will be mentioned in the README.md file as a backer ❤️.

<a href='https://ko-fi.com/Q5Q7PPTYK' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>

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

```bash
export GITHUB_TOKEN="your_github_token"
$ git clone https://github.com/aiKrice/badgetizr.git
# edit the .badgetizr.yml file to your needs
$ export GITHUB_TOKEN="your_github_token"
$ export BADGETIZR_BUILD_NUMBER="123" # the build number of your CI
$ export BADGETIZR_BUILD_URL="https://your-shiny-ci.io/app/build/123" # the build url of your CI
$ export BADGETIZR_PR_DESTINATION_BRANCH="develop" # the destination branch of your PR from the CI.
$ cd badgetizr && ./configure
```

Then you can run the configure script and the badgetizer script:
## Usage
```bash
$ ./configure && ./badgetizer.sh
$ ./badgetizer.sh
```

By default, the configuration file used is `.badgetizr.yml`. You can also specify a configuration file to use by using the `-c` option.
```bash
$ ./badgetizer.sh -c my_config.yml
```

## Configuration
Expand Down
52 changes: 52 additions & 0 deletions badgetizr.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,59 @@
#!/bin/bash

# Read config file

show_help() {
cat <<EOF
Usage: $0 [options]
Options :
-c <file>,
--configuration=<file>,
--configuration <file> Specify a configuration file. By default, the configuration file used is : .badgetizr.yml
--help Display this help.
EOF
}

config_file=".badgetizr.yml"

while getopts "c:-:" opt; do
case $opt in
c)
config_file="$OPTARG"
;;
-)
case "${OPTARG}" in
configuration=*)
config_file="${OPTARG#*=}"
;;

configuration)
config_file="${!OPTIND}"; OPTIND=$(( OPTIND + 1 ))
;;

help)
show_help
exit 0
;;

*)
echo "Option invalide --${OPTARG}" >&2
echo "Utilisez --help pour plus d'informations." >&2
exit 1
;;
esac
;;

\?)
echo "Option invalide : -$OPTARG" >&2
echo "Utilisez --help pour plus d'informations." >&2
exit 1
;;
esac
done

if [ -f "$config_file" ]; then
wip_badge_enabled=$(yq e '.badge_wip.enabled // "true"' "$config_file")
wip_badge_label=$(yq e '.badge_wip.settings.label // "Work in Progress"' "$config_file")
Expand Down

0 comments on commit e8cab95

Please sign in to comment.