-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from georgepstaylor/initial
🎉 Add initial workflow
- Loading branch information
Showing
4 changed files
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Create gitmoji label | ||
on: | ||
pull_request: | ||
types: [opened, edited, reopened, synchronize] | ||
jobs: | ||
create-gitmoji-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Enforce gitmoji PR title | ||
uses: georgepstaylor/gitmoji-auto-label@${{github.sha}} | ||
with: | ||
GITHUB_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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ |
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 |
---|---|---|
@@ -1,2 +1,21 @@ | ||
# gitmoji-auto-label | ||
|
||
|
||
A simple action to automatically label PRs based on the gitmoji used in the title. | ||
|
||
## Usage | ||
```yaml | ||
name: Create gitmoji label | ||
on: | ||
pull_request: | ||
types: [opened, edited, reopened, synchronize] | ||
jobs: | ||
create-gitmoji-label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Enforce gitmoji PR title | ||
uses: georgepstaylor/[email protected] | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
Using the above example verbatim, you can use the job title `gitmoji-pr-title` as a required check. |
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,43 @@ | ||
--- | ||
name: Auto create gitmoji labels | ||
description: This action automatically creates gitmoji labels JIT | ||
|
||
inputs: | ||
GITHUB_TOKEN: | ||
description: 'GitHub token' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get all Gitmoji's | ||
id: gitmojis | ||
shell: bash | ||
run: | | ||
curl -s https://gitmoji.dev/api/gitmojis | jq '.gitmojis[].emoji' > gitmojis.txt | ||
- name: Get gitmoji from PR title | ||
id: get-gitmoji | ||
shell: bash | ||
run: | | ||
gitmojis=$(cat gitmojis.txt) | ||
gitmoji=$(echo "${{ github.event.pull_request.title }}" | cut -d ' ' -f1) | ||
if [[ ! $gitmojis == *"$gitmoji"* ]]; then | ||
echo "Invalid gitmoji prefix in PR title. Please use a valid gitmoji prefix." | ||
exit 1 | ||
else | ||
echo "gitmoji=$gitmoji" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Create label if not exists | ||
id: create-label | ||
shell: bash | ||
run: | | ||
gitmoji=$(cat $GITHUB_OUTPUT | grep gitmoji | cut -d '=' -f2) | ||
random_hex_color=$(openssl rand -hex 3) | ||
label_exists=$(curl -s -H "Authorization : token ${{ inputs.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/labels | jq '.[].name' | grep ${gitmoji}_gitmoji) | ||
if [[ -z $label_exists ]]; then | ||
curl -s -H "Authorization: token ${{ inputs.GITHUB_TOKEN }}" -X POST https://api.github.com/repos/${{ github.repository }}/labels -d "{\"name\":\"${gitmoji}_gitmoji\",\"color\":\"$random_hex_color\"}" | ||
fi | ||
branding: | ||
icon: 'check-circle' | ||
color: 'green' |