Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Github Action to validate PR commits #8

Merged
merged 2 commits into from
Jul 15, 2023
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
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 }}"
```