Skip to content
Closed
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
47 changes: 47 additions & 0 deletions .github/workflows/conventional-commits-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: đź“‹ Conventional Commits Example

# This is an example workflow showing how to use all three conventional commits workflows
# Copy this to your repository and customize as needed

on:
pull_request:
branches: [ main, master ]
types: [opened, edited, reopened, synchronize]
push:
branches: [ main, master ]

jobs:
# Validate commit messages in PRs
validate-commits:
if: github.event_name == 'pull_request'
uses: clouddrove/github-shared-workflows/.github/workflows/conventional-commits-lint.yml@master
with:
allowed_types: "feat,fix,docs,style,refactor,perf,test,chore,ci,build,revert"
scopes: "api,ui,docs,config,deploy,infra"
breaking_change_token: "BREAKING CHANGE"
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Validate PR titles
validate-pr-title:
if: github.event_name == 'pull_request'
uses: clouddrove/github-shared-workflows/.github/workflows/conventional-commits-pr-title.yml@master
with:
allowed_types: "feat,fix,docs,style,refactor,perf,test,chore,ci,build,revert"
scopes: "api,ui,docs,config,deploy,infra"
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Create releases on push to main/master
release:
if: github.event_name == 'push'
uses: clouddrove/github-shared-workflows/.github/workflows/conventional-commits-release.yml@master
with:
target_branch: master
initial_version: "1.0.0"
prerelease: false
changelog_file: "CHANGELOG.md"
version_prefix: "v"
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/conventional-commits-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: 🔍 Conventional Commits Lint

on:
workflow_call:
inputs:
allowed_types:
required: false
type: string
default: "feat,fix,docs,style,refactor,perf,test,chore,ci,build,revert"
description: 'Comma-separated list of allowed commit types'
scopes:
required: false
type: string
default: ""
description: 'Comma-separated list of allowed scopes (optional)'
breaking_change_token:
required: false
type: string
default: "BREAKING CHANGE"
description: 'Token to identify breaking changes'
secrets:
GITHUB_TOKEN:
required: false
description: 'GitHub token for private repositories'

jobs:
conventional-commits-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: 📦 Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: 🔍 Validate Conventional Commits
uses: webiny/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
allowed-commit-types: ${{ inputs.allowed_types }}
scopes: ${{ inputs.scopes }}
breaking-change-token: ${{ inputs.breaking_change_token }}

- name: đź“‹ Summary
run: |
echo "âś… All commit messages follow Conventional Commits specification"
echo "📝 Allowed types: ${{ inputs.allowed_types }}"
if [ -n "${{ inputs.scopes }}" ]; then
echo "🎯 Allowed scopes: ${{ inputs.scopes }}"
fi
echo "đź’Ą Breaking change token: ${{ inputs.breaking_change_token }}"
47 changes: 47 additions & 0 deletions .github/workflows/conventional-commits-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: 📝 PR Title Conventional Commits Check

on:
workflow_call:
inputs:
allowed_types:
required: false
type: string
default: "feat,fix,docs,style,refactor,perf,test,chore,ci,build,revert"
description: 'Comma-separated list of allowed commit types'
scopes:
required: false
type: string
default: ""
description: 'Comma-separated list of allowed scopes (optional)'
secrets:
GITHUB_TOKEN:
required: false
description: 'GitHub token for private repositories'

jobs:
pr-title-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: 📦 Checkout repository
uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: 🔍 Validate PR Title
uses: Namchee/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
allowed_types: ${{ inputs.allowed_types }}
scopes: ${{ inputs.scopes }}

- name: đź“‹ Summary
run: |
echo "âś… PR title follows Conventional Commits specification"
echo "📝 Allowed types: ${{ inputs.allowed_types }}"
if [ -n "${{ inputs.scopes }}" ]; then
echo "🎯 Allowed scopes: ${{ inputs.scopes }}"
fi
echo "đź“„ PR Title: ${{ github.event.pull_request.title }}"
124 changes: 124 additions & 0 deletions .github/workflows/conventional-commits-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
name: 🚀 Conventional Commits Release

on:
workflow_call:
inputs:
target_branch:
required: true
type: string
default: master
description: 'Target branch for releases'
initial_version:
required: false
type: string
default: "1.0.0"
description: 'Initial version if no tags exist'
prerelease:
required: false
type: boolean
default: false
description: 'Create prerelease versions'
changelog_file:
required: false
type: string
default: "CHANGELOG.md"
description: 'Changelog file path'
version_prefix:
required: false
type: string
default: "v"
description: 'Version prefix (e.g., v for v1.0.0)'
secrets:
GITHUB_TOKEN:
required: true
description: 'GitHub token for creating releases and tags'

jobs:
conventional-release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', inputs.target_branch)

steps:
- name: 📦 Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: đź§© Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq

- name: 🔍 Determine next version
id: version
uses: smlx/[email protected]
with:
write-tag: false
initial-version: ${{ inputs.initial_version }}
prerelease: ${{ inputs.prerelease }}
version-prefix: ${{ inputs.version_prefix }}

- name: 📝 Generate changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.version.outputs.version }}
includeInvalidCommits: false
writeToFile: true
changelogFilePath: ${{ inputs.changelog_file }}
includeRefIssues: true
useGitmojis: true
reverseOrder: false

- name: 🏷️ Create and push tag
if: steps.version.outputs.version != ''
run: |
git config user.name "clouddrove-ci"
git config user.email "[email protected]"
git tag ${{ steps.version.outputs.version }}
git push origin ${{ steps.version.outputs.version }}

- name: 🚀 Create GitHub release
if: steps.version.outputs.version != ''
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
allowUpdates: true
draft: false
prerelease: ${{ inputs.prerelease }}
makeLatest: true
body: |
${{ steps.changelog.outputs.changes }}

**Release Type:** ${{ steps.version.outputs.version_type }}

[Compare changes](https://github.com/${{ github.repository }}/compare/${{ steps.version.outputs.previous_version }}...${{ steps.version.outputs.version }})

- name: đź’ľ Commit changelog
if: steps.version.outputs.version != ''
uses: stefanzweifel/git-auto-commit-action@v6
with:
branch: ${{ inputs.target_branch }}
commit_user_name: clouddrove-ci
commit_user_email: [email protected]
commit_author: "CloudDrove CI <[email protected]>"
commit_message: 'docs: update ${{ inputs.changelog_file }} for ${{ steps.version.outputs.version }}'
file_pattern: ${{ inputs.changelog_file }}

- name: đź“‹ Release summary
run: |
if [ -n "${{ steps.version.outputs.version }}" ]; then
echo "âś… Released ${{ steps.version.outputs.version }} successfully"
echo "🏷️ Version type: ${{ steps.version.outputs.version_type }}"
echo "📝 Changelog updated: ${{ inputs.changelog_file }}"
if [ "${{ inputs.prerelease }}" == "true" ]; then
echo "đź”– This is a prerelease"
fi
else
echo "ℹ️ No new version to release"
fi
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Above example is just a simple example to call workflow from github shared workf
27. [Terraform Workflow](./docs/27.terraform_workflow.md)
28. [Terraform Module Tag Release Workflow (Shared)](./docs/28.tf-monorepo-tag-release.md)
29. [Terraform PR Plan Diff workflow](./docs/29.tf-pr-checks.md)
30. [Conventional Commits Workflows](./docs/30.conventional-commits.md)

## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/github-shared-workflows/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
Expand Down
Loading
Loading