Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: 👷 add release drafter auto labeler github action #18

Merged
merged 21 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# https://github.com/actions/labeler

# In some configurations (like Release Drafter), regex is enclosed with slashes (e.g., /build\/.+/), which signifies the start and end of the regular expression.
# However, in GitHub Actions' labeler.yml, you do not need to wrap your regex patterns in slashes. The tool expects just the regex itself, without the delimiters.

ansible:
- changed-files:
- any-glob-to-any-file:
- '.ansible-lint'
- 'ansible.cfg'
- 'ansible/*'
- 'molecule/*'

configuration:
- changed-files:
- any-glob-to-any-file:
- '.github/*yml'
- '.gitignore'
- '.gitattributes'
- '.vscode/*'
- '.devcontainer/*'
- '.editorconfig'
- '.yamllint.yml'
- '.ansible-lint'

docker:
- changed-files:
- any-glob-to-any-file:
- '**/Dockerfile'
- '**/docker-compose.yml'
- '**/docker-compose.yaml'
- '**/docker-compose.test.yml'

github:
- any:
- changed-files:
- any-glob-to-any-file:
- '.github/*'
- '!.github/workflows/'

source:
- all:
- changed-files:
- any-glob-to-any-file: 'src/**/*'
- all-globs-to-all-files: '!src/docs/*'

policy:
- changed-files:
- any-glob-to-any-file:
- '.github/ISSUE_TEMPLATE/*'
- '.github/PULL_TEMPLATE/*'
- 'LICENSE'
- 'SECURITY.md'

terraform:
- changed-files:
- any-glob-to-any-file:
- 'terraform/*'
- '**/*.tf'
- '**/*.lock.hcl'

vscode:
- changed-files:
- any-glob-to-any-file:
- '.vscode/*'

feature:
- head-branch:
- '^(feat)(\([a-z ]+\))?\/.'
- '^(feature)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- src/*

ci-cd:
- head-branch:
- '^(ci)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- '.github/workflows/*'
- '.github/*'

devops:
- head-branch:
- '^(ci)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- 'deployments/*'
- '.github/workflows/*'
- '.github/*'
- 'terraform/*'
- '**/*.tf'
- '**/*.lock.hcl'
- '**/Dockerfile'
- '**/docker-compose.yml'
- '**/docker-compose.yaml'
- '**/docker-compose.test.yml'

style:
- head-branch:
- '^(style)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- src/*

documentation:
- head-branch:
- '^(docs)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- '**/*.md'
- '**/*.rst'
- '**/*.txt'
- docs/**
- guides/*

performance:
- head-branch:
- '^(perf)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- src/*

bug:
- head-branch:
- '^(fix)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- src/*

enhancement:
- head-branch:
- '^(refactor)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- src/*

build:
- head-branch:
- '^(build)(\([a-z ]+\))?\/.'

dependencies:
- head-branch:
- '^(build)(\([a-z ]+\))?\/.'

chore:
- head-branch:
- '^(chore)(\([a-z ]+\))?\/.'
- changed-files:
- all-globs-to-all-files: '!src/*'
- all-globs-to-all-files: '!tests/*'
- all-globs-to-all-files: '!.github/*'

test:
- head-branch:
- '^(test)(\([a-z ]+\))?\/.'
- changed-files:
- any-glob-to-any-file:
- 'test/*'
- 'molecule/*'
- 'docker-compose.test.yml'

minor:
- head-branch:
- '^(feat)(\([a-z ]+\))?\/.'

patch:
- head-branch:
- '^(fix)(\([a-z ]+\))?\/.'
- '^(ci)(\([a-z ]+\))?\/.'
87 changes: 87 additions & 0 deletions .github/multi-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# https://github.com/fuxingloh/multi-labeler
# https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax
version: v1

labels:
- label: "feature"
matcher:
title: '^(feat)(\([a-z ]+\))?: .'
commits: '^(feat)(\([a-z ]+\))?: .'
branch: '^(feat)(\([a-z ]+\))?\/.'

- label: "bug"
matcher:
title: '^(fix)(\([a-z ]+\))?: .'
commits: '^(fix)(\([a-z ]+\))?: .'
branch: '^(fix)(\([a-z ]+\))?\/.'

- label: "chore"
matcher:
title: '^(chore)(\([a-z ]+\))?: .'
commits: '^(chore)(\([a-z ]+\))?: .'
branch: '^(chore)(\([a-z ]+\))?\/.'

- label: "documentation"
matcher:
title: '^(docs)(\([a-z ]+\))?: .'
commits: '^(docs)(\([a-z ]+\))?: .'
branch: '^(docs)(\([a-z ]+\))?\/.'

- label: "devops"
matcher:
title: '^(ci)(\([a-z ]+\))?: .'
commits: '^(ci)(\([a-z ]+\))?: .'
branch: '^(ci)(\([a-z ]+\))?\/.'

- label: "ci-cd"
matcher:
title: '^(ci)(\([a-z ]+\))?: .'
commits: '^(ci)(\([a-z ]+\))?: .'
branch: '^(ci)(\([a-z ]+\))?\/.'

- label: "enhancement"
matcher:
title: '^(refactor)(\([a-z ]+\))?: .'
commits: '^(refactor)(\([a-z ]+\))?: .'
branch: '^(refactor)(\([a-z ]+\))?\/.'

- label: "style"
matcher:
title: '^(style)(\([a-z ]+\))?: .'
commits: '^(style)(\([a-z ]+\))?: .'
branch: '^(style)(\([a-z ]+\))?\/.'

- label: "performance"
matcher:
title: '^(perf)(\([a-z ]+\))?: .'
commits: '^(perf)(\([a-z ]+\))?: .'
branch: '^(perf)(\([a-z ]+\))?\/.'

- label: "build"
matcher:
title: '^(build)(\([a-z ]+\))?: .'
commits: '^(build)(\([a-z ]+\))?: .'
branch: '^(build)(\([a-z ]+\))?\/.'

- label: "test"
matcher:
title: '^(test)(\([a-z ]+\))?: .'
commits: '^(test)(\([a-z ]+\))?: .'
branch: '^(test)(\([a-z ]+\))?\/.'

- label: "dependencies"
matcher:
title: '^build\(deps\): .'
commits: '^build\(deps\): .'

- label: "minor"
matcher:
title: '^(feat)(\([a-z ]+\))?: .'
commits: '^(feat)(\([a-z ]+\))?: .'
branch: '^(feat)(\([a-z ]+\))?\/.'

- label: "patch"
matcher:
title: '^(fix)(\([a-z ]+\))?: .'
commits: '^(fix)(\([a-z ]+\))?: .'
branch: '^(fix)(\([a-z ]+\))?\/.'
49 changes: 26 additions & 23 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ categories:
- title: 🚀 Features
labels:
- feature
- feat
- title: ♻️ Enhancement
labels:
- enhancement
Expand All @@ -29,9 +30,12 @@ categories:
- title: 👷 CI
labels:
- ci
- ci-cd
- devops
- title: ⚠️ Breaking Changes
labels:
- breaking-changes
- major
- title: ⛔️ Deprecated
labels:
- deprecated
Expand All @@ -41,6 +45,9 @@ categories:
- title: 🔐 Security
labels:
- security
- title: 🎨 Style & Formatting
labels:
- style
- title: 🧪 Test
labels:
- test
Expand All @@ -51,6 +58,7 @@ categories:
- title: 🧩 Dependency Updates
labels:
- deps
- build
- dependencies
- title: 🧰 Maintenance
label: 'chore'
Expand All @@ -59,53 +67,48 @@ categories:
- title: 🚩 Other changes
## putting no labels pr to `Other Changes` category with no label - https://github.com/release-drafter/release-drafter/issues/139#issuecomment-480473934


# https://www.trywilco.com/post/wilco-ci-cd-github-heroku
# https://github.com/release-drafter/release-drafter#autolabeler
# https://github.com/fuxingloh/multi-labeler

# Using regex for defining rules - https://regexr.com/
# https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax
# Auto-labeler: Assign labels based on branch names or PR titles that follow Conventional Commits
autolabeler:
- label: 'chore'
- label: "chore"
branch:
- '(chore)(\([a-z ]+\))?\/.'
- '^(chore)(\([a-z ]+\))?\/.'
title:
- '^(chore)(\([a-z ]+\))?: .'
- label: 'bug'
- label: "bug"
branch:
- '(fix)(\([a-z ]+\))?\/.'
- '^(fix)(\([a-z ]+\))?\/.'
title:
- '^(fix)(\([a-z ]+\))?: .'
- label: 'refactor'
branch:
- '(refactor)(\([a-z ]+\))?\/.'
title:
- '^(refactor)(\([a-z ]+\))?: .'
- label: 'test'
- label: "feature"
branch:
- '(test)(\([a-z ]+\))?\/.'
- '^(feat)(\([a-z ]+\))?\/.'
title:
- '^(test)(\([a-z ]+\))?: .'
- label: 'feature'
- '^(feat)(\([a-z ]+\))?: .'
- label: "style"
branch:
- '(feat)(\([a-z ]+\))?\/.'
- '^(style)(\([a-z ]+\))?\/.'
title:
- '^(feat)(\([a-z ]+\))?: .'
- label: 'ci/cd'
- '^(style)(\([a-z ]+\))?: .'
- label: "ci-cd"
branch:
- '(ci)(\([a-z ]+\))?\/.'
- '^(ci)(\([a-z ]+\))?\/.'
title:
- '^(ci)(\([a-z ]+\))?: .'
- label: 'minor'
- label: "minor"
branch:
- '(feat)(\([a-z ]+\))?\/.'
- '^(feat)(\([a-z ]+\))?\/.'
title:
- '^(feat)(\([a-z ]+\))?: .'
- label: 'patch'
- label: "patch"
branch:
- '(fix)(\([a-z ]+\))?\/.'
- '(ci)(\([a-z ]+\))?\/.'
- '^(fix)(\([a-z ]+\))?\/.'
- '^(ci)(\([a-z ]+\))?\/.'
title:
- '^(fix)(\([a-z ]+\))?: .'
- '^(ci)(\([a-z ]+\))?: .'
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ jobs:
- uses: actions/checkout@v3

- name: Conventional Commits Check
uses: webiny/[email protected]
uses: amannn/action-semantic-pull-request@v5
if: always()
id: check-pull-request-title-conventional-commits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v3
Expand Down
Loading
Loading