Skip to content

Commit

Permalink
feat: add pr-validate-title-conventional
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Apr 13, 2023
1 parent b458c5c commit ad1b7a4
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,42 @@ Assign the author of a pull request to the pull request. For use with the `pull_
| false | `app-id` | The app ID of the app. | `${{ secrets.APP_ID }}` ||
| false | `private-key` | The private key of the app. | `${{ secrets.APP_PRIVATE_KEY }}` ||

#### pr-validate-title-conventional

[Source](pr-validate-title-conventional/action.yml)

Validate the title of a pull request based on the conventional commit format. For use with the `pull_request` event.

##### Example

```yaml
- uses: myparcelnl/actions/pr-validate-title-conventional@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

# Or, if you want to use a GitHub app:

- uses: myparcelnl/actions/pr-validate-title-conventional@v3
with:
app-id: ${{ secrets.GITHUB_APP_ID }}
private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }}
```

##### Inputs

| Required | Name | Description | Example | Default |
| -------- | ------------- | ------------------------------------------------------------------------------------------------ | -------------------------------- | ------- |
| false | `token` | GitHub token to use. If passed, takes precedence over the `app-id` and `app-private-key` inputs. | `${{ secrets.GITHUB_TOKEN }}` ||
| false | `app-id` | The app ID of the app. | `${{ secrets.APP_ID }}` ||
| false | `private-key` | The private key of the app. | `${{ secrets.APP_PRIVATE_KEY }}` ||

##### Outputs

| Name | Description | Example |
| --------- | ---------------------------------------- | ------------------------------- |
| `success` | Whether the PR title is valid. | `true` |
| `error` | Error in case the PR title is not valid. | `(string containing the error)` |

### Miscellaneous

#### bundlewatch
Expand Down
43 changes: 43 additions & 0 deletions pr-validate-title-conventional/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Validate PR title'
description: 'Validate pull request title based on the conventional commits convention'

inputs:
token:
description: 'GitHub token to use. If passed, takes precedence over the `app-id` and `app-private-key` inputs.'

app-id:
description: 'The app ID of the app.'

private-key:
description: 'The private key of the app.'

outputs:
success:
description: 'Whether the PR title is valid'
value: ${{ steps.validate.outputs.success }}

error:
description: 'Error in case the PR title is not valid'
value: ${{ steps.validate.outputs.error }}

runs:
using: composite
steps:
- uses: actions/checkout@v3

- uses: ./get-github-token
id: token
with:
token: ${{ inputs.token }}
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.private-key }}

- uses: aslafy-z/conventional-pr-title-action@v3
id: validate
continue-on-error: true
with:
context-name: 'Validate pull request title'
success-state: 'Title follows conventional commits convention'
failure-state: 'Title does not follow conventional commits convention'
env:
GITHUB_TOKEN: ${{ steps.token.outputs.token }}

0 comments on commit ad1b7a4

Please sign in to comment.