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
16 changes: 9 additions & 7 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ jobs:
validateSingleCommit: ${{ inputs.validateSingleCommit }}

- name: 🏷️ Check PR labels
if: ${{ inputs.checkLabels }}
if: ${{ inputs.checkLabels && github.event.pull_request.head.repo.fork == false }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -z "$(gh api repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/labels --jq '.[].name')" ]; then
labels=$(gh api repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/labels --jq '.[].name')

if [ -z "$labels" ]; then
echo "::error::No labels found on this PR. Please add at least one label."
exit 1
else
echo "PR has labels, validation passed."
echo "PR has labels"
fi

validate-commits:
Expand All @@ -75,8 +77,8 @@ jobs:
with:
fetch-depth: 0

- name: 🧾 Validate Commit Messages
uses: webiny/action-conventional-commits@v1.3.1
- name: 🧾 Commitlint Validation (Inline Config)
uses: wagoid/commitlint-github-action@v6
with:
allowed-commit-types: ${{ inputs.types }}
configFile: commitlint.config.cjs
...
19 changes: 19 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', [
'fix',
'feat',
'docs',
'ci',
'chore',
'test',
'refactor',
'style',
'perf',
'build',
'revert'
]],
'header-max-length': [2, 'always', 100]
}
};
65 changes: 65 additions & 0 deletions docs/pr-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,71 @@ Automatically validates:
### Usage
This workflow triggers automatically on PR events and can be configured with input parameters.

### 1️⃣ PR Title Validation
- Using [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request/blob/main/README.md)
- Ensures PR titles follow Conventional Commits format.
- Example:

βœ… Valid

```
feat(api): Add login endpoint
fix: Resolve token issue
docs(readme): Update installation guide
```

❌ Invalid
```
update login
bug fix
added new feature
```

**🏷️ Check PR labels**
| **PR Type** | **Label Validation** |
|--------------------|--------------------------|
| Internal PR | βœ… checked |
| Fork PR | ⏭ skipped |

#### **Example flow**
Internal contributor

PR β†’ validation runs:
```
PR title βœ”
commits βœ”
labels βœ”
```

Fork contributor

PR β†’ validation runs:
```
PR title βœ”
commits βœ”
labels ⏭ skipped
```

### 2️⃣ Commit Message Validation
- Using [wagoid/commitlint-github-action](https://github.com/wagoid/commitlint-github-action/blob/master/README.md)
- Ensures all commits follow Conventional Commit format.
- Example:

βœ… Valid commits

```
feat(api): add login endpoint
fix(auth): resolve token issue
docs: update readme
```
❌ Invalid

```
update code
bug fix
changes
```

#### Example Implementation
```yaml
name: 'PR Validation'
Expand Down
Loading