-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
181 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Run Badgetizr on Pull Requests | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- edited | ||
- closed | ||
|
||
jobs: | ||
badgetizr: | ||
runs-on: ubuntu-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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,7 @@ _📣 I would like to put this tool available with Homebrew and Apt-Get. To succ | |
- [x] Add the tools to Homebrew tap | ||
- [ ] Add the tool to Homebrew | ||
- [ ] Add the tool to Apt-Get | ||
- [ ] Add the tools to Github Actions | ||
- [ ] Add the tools to Github Marketplace | ||
- [x] Add the tools to Github Actions | ||
- [ ] Support natively Gitlab with `glab` CLI | ||
|
||
To see how to contribute, please refer to the section [Contributing](#contributing). | ||
|
@@ -66,7 +65,7 @@ $ ./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 | ||
## Usage (CLI) | ||
```bash | ||
$ badgetizr #[options] | ||
``` | ||
|
@@ -75,6 +74,30 @@ 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. | ||
```yaml | ||
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. | ||
```bash | ||
|
@@ -93,7 +116,7 @@ If you want to use an icon for your badge, you can use the `icon` option and spe | |
#### 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. | ||
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"'`. | ||
|
||
#### Configuration: | ||
- `color`: The color of the badge (default: `blue`). | ||
|
@@ -185,8 +208,9 @@ $ ./configure #optional, just for dependencies | |
$ ./badgetizer.sh | ||
``` | ||
|
||
## Release (for maintainers) | ||
To release the tool, you can run the `deploy-homebrew.sh` script by providing the version you want to release. Please respect the semantic versioning notation. | ||
## 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. | ||
```bash | ||
./deploy-homebrew.sh 1.1.3 | ||
./publish.sh 1.1.3 | ||
``` | ||
This script will bump everything possible to keep everything up-to-date. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: 'Badgetizr' | ||
description: 'A GitHub Action to run Badgetizr for custom PR badges' | ||
inputs: | ||
pr_id: | ||
description: 'Specify the path to the configuration. Default is .badgetizr.yml' | ||
required: true | ||
configuration: | ||
description: 'The path to the configuration. Default is .badgetizr.yml' | ||
required: false | ||
default: '.badgetizr.yml' | ||
pr_destination_branch: | ||
description: '(Mandatory when branch badge is enabled) Specify the pull request destination branch' | ||
required: false | ||
pr_build_number: | ||
description: '(Mandatory when CI badge is enabled) Specify the pull request build number' | ||
required: false | ||
pr_build_url: | ||
description: '(Mandatory when CI badge is enabled) Specify the pull request build url' | ||
required: false | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install dependencies | ||
run: | | ||
if [[ "$(uname)" == "Darwin" ]]; then | ||
echo "Running on macOS" | ||
if ! command -v gh &> /dev/null; then | ||
echo "GitHub CLI (gh) not found. Installing..." | ||
brew install gh | ||
fi | ||
if ! command -v yq &> /dev/null; then | ||
echo "yq not found. Installing..." | ||
brew install yq | ||
fi | ||
else | ||
echo "Running on Linux" | ||
if ! command -v gh &> /dev/null; then | ||
echo "GitHub CLI (gh) not found. Installing..." | ||
sudo apt-get update | ||
sudo apt-get install -y gh | ||
fi | ||
if ! command -v yq &> /dev/null; then | ||
echo "yq not found. Installing..." | ||
sudo apt-get install -y yq | ||
fi | ||
fi | ||
shell: bash | ||
- name: "Execute Badgetizr" | ||
run: | | ||
pr_id="${{ inputs.pr_id }}" | ||
configuration="${{ inputs.configuration }}" | ||
pr_destination_branch="${{ inputs.pr_destination_branch }}" | ||
pr_build_number="${{ inputs.pr_build_number }}" | ||
pr_build_url="${{ inputs.pr_build_url }}" | ||
options="" | ||
if [ -n "$pr_id" ]; then | ||
options="$options --pr-id=$pr_id" | ||
fi | ||
if [ -n "$pr_destination_branch" ]; then | ||
options="$options --pr-destination-branch $pr_destination_branch" | ||
fi | ||
if [ -n "$pr_build_number" ]; then | ||
options="$options --pr-build-number $pr_build_number" | ||
fi | ||
if [ -n "$pr_build_url" ]; then | ||
options="$options --pr-build-url $pr_build_url" | ||
fi | ||
chmod +x ./badgetizr.sh | ||
./badgetizr.sh -c $configuration $options | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters