Skip to content
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
61 changes: 1 addition & 60 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,63 +11,4 @@ permissions:

jobs:
validate-commit-names:
name: Check Commit Names
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
with:
# Limit of validation to skip fetching all existing commits
fetch-depth: 100

# Validate commit messages
- name: Validate all commit messages
run: |
echo "Validating all commit names in PR #${{ github.event.pull_request.number }}"

# Get the base branch and the PR branch
BASE_BRANCH="${{ github.event.pull_request.base.ref }}"

# Fetch the base branch with no verbosity
git fetch --quiet origin "$BASE_BRANCH"

# Get all commits in the PR (not the base branch ones)
# --pretty=format:"%s" gets only the commit message
mapfile -t commits_array < <(git log origin/$BASE_BRANCH..HEAD --pretty=format:'%s')

# Regex pattern for valid Conventional Commit
regex='^(docs|fix|feat|chore|refactor|test|style|build|ci): [a-z].{9,}$'

# Variable to count errors
fail=0

echo "Commit list and validation:"

# Print and validate
for commitmsg in "${commits_array[@]}"; do
echo "$commitmsg"

# Skip merge and [tx] commits
if [[ "$commitmsg" =~ ^Merge ]] || [[ "$commitmsg" =~ ^\[tx\] ]] || [[ "$commitmsg" =~ SBOM\ updated ]]; then
echo " 🚫 Ignored commit"
continue
fi

# Validate Conventional Commit
if ! [[ "$commitmsg" =~ $regex ]]; then
echo " ❌ Invalid commit"
fail=$((fail+1))
else
echo " ✅ Valid commit"
fi
done

# Fail the job if there are any invalid commits
if [[ $fail -gt 0 ]]; then
echo "❌ $fail commit(s) do(es) not follow the Conventional Commits convention"
exit 1
else
echo "✅ All commits follow the Conventional Commits convention"
fi
uses: owncloud/reusable-workflows/.github/workflows/semantic-git-message.yml@main
5 changes: 5 additions & 0 deletions changelog/unreleased/4832
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Use reusable workflow for Conventional commits

A new reusable workflow to validate Conventional commits has been added to the current workflow in order to be used by all clients

https://github.com/owncloud/android/pull/4832
Loading