diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml index f7e99fb6a9e..b3ce51b6eaf 100644 --- a/.github/workflows/conventional-commits.yml +++ b/.github/workflows/conventional-commits.yml @@ -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 diff --git a/changelog/unreleased/4832 b/changelog/unreleased/4832 new file mode 100644 index 00000000000..40fcc751a5a --- /dev/null +++ b/changelog/unreleased/4832 @@ -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