Skip to content

Commit

Permalink
feat: support Github Action to validate PR commits (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyiso authored Jul 15, 2023
1 parent 40105b0 commit e94ee53
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/pr_commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize]

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- uses: dart-lang/setup-dart@v1.3

- name: Get Dependencies
run: dart pub get

- name: Validate PR Commits
run: VERBOSE=true dart run commitlint_cli --from="origin/${{ github.base_ref }}" --to="${{ github.head_ref }}" --config lib/commitlint.yaml
31 changes: 29 additions & 2 deletions docs/guides-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ No staged files match any of provided globs.
husky - commit-msg hook exited with code 1 (add --no-verify to bypass)
```

## Setup Github CI
## Setup Github Actions

### Validate PR Title
Add `.github/workflows/pr_title.yml`
```yaml
on:
Expand All @@ -83,4 +84,30 @@ jobs:

- name: Validate Title of PR
run: echo ${{ github.event.pull_request.title }} | dart run commitlint_cli
```
```
### Validate PR Commits
Add `.github/workflows/pr_commits.yml`
```yaml
on:
pull_request:
branches: [ "main" ]
types: [opened, synchronize]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: dart-lang/setup-dart@v1.3
- name: Get Dependencies
run: dart pub get
- name: Validate PR Commits
run: dart run commitlint_cli --from="origin/${{ github.base_ref }}" --to="${{ github.head_ref }}"
```

0 comments on commit e94ee53

Please sign in to comment.