All Projects → amannn → action-semantic-pull-request

amannn / action-semantic-pull-request

Licence: MIT license
A GitHub Action that ensures that your PR title matches the Conventional Commits spec.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to action-semantic-pull-request

autoupdate
A GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
Stars: ✭ 70 (-81.43%)
Mutual labels:  pull-requests, github-action
pr-reviews-reminder-action
A GitHub Action to send Slack/Teams notification for Pull Request that are waiting for reviewers.
Stars: ✭ 18 (-95.23%)
Mutual labels:  pull-requests, github-action
merge-request-notifier
This app shows your merge requests grouped by projects and WIP status. It is accessible from the system tray.
Stars: ✭ 47 (-87.53%)
Mutual labels:  pull-requests
github-deploy-actions
This action will auto deploy to target branch when it get triggered
Stars: ✭ 24 (-93.63%)
Mutual labels:  github-action
Hacktoberfest-2021
Make this Hacktoberfest a learning period and contribute to Great Open Source Projects.
Stars: ✭ 523 (+38.73%)
Mutual labels:  pull-requests
standard-action
Github Action to lint with `standard` and friends
Stars: ✭ 15 (-96.02%)
Mutual labels:  github-action
hacktoberfest-2019
You can check the video here: #hacktoberfest
Stars: ✭ 28 (-92.57%)
Mutual labels:  pull-requests
HacktoberFest2020
🤗Feel free to submit a PR💻 to have it merged and get a free Hacktoberfest tee👕 from Github🔮. Updated as per new guidelines✔️
Stars: ✭ 22 (-94.16%)
Mutual labels:  pull-requests
actions-aws-eb
Elastic beanstalk cli custom action
Stars: ✭ 39 (-89.66%)
Mutual labels:  github-action
Github-Android-Action
Android Github Action that builds Android project, runs unit tests and generates debug APK, builds for Github Actions hackathon
Stars: ✭ 29 (-92.31%)
Mutual labels:  github-action
github-rebase-bot
A github bot that monitors repository PRs, rebases them and merges them as they pass tests
Stars: ✭ 29 (-92.31%)
Mutual labels:  pull-requests
turbogit
Opinionated cli enforcing clean git workflow without comprising UX
Stars: ✭ 42 (-88.86%)
Mutual labels:  conventional-commits
googlejavaformat-action
GitHub Action that formats Java files following Google Style guidelines
Stars: ✭ 66 (-82.49%)
Mutual labels:  github-action
critiq.vim
Github code reviews from Neovim
Stars: ✭ 69 (-81.7%)
Mutual labels:  pull-requests
create-or-update-project-card
A GitHub action to create or update a project card
Stars: ✭ 36 (-90.45%)
Mutual labels:  github-action
github-action-required-labels
Fail the build if/unless a certain combination of labels are applied to a pull request
Stars: ✭ 38 (-89.92%)
Mutual labels:  github-action
clojure-dependency-update-action
A simple GitHub Actions job to create Pull Requests for outdated dependencies in clojure projects
Stars: ✭ 37 (-90.19%)
Mutual labels:  github-action
setup-gcc
GitHub action to set up GCC
Stars: ✭ 51 (-86.47%)
Mutual labels:  github-action
translation-action
GitHub action that translates any text to any language supported by chosen provider.
Stars: ✭ 25 (-93.37%)
Mutual labels:  github-action
get-cmake
Install and Cache latest CMake and ninja executables for your workflows on your GitHub
Stars: ✭ 52 (-86.21%)
Mutual labels:  github-action

action-semantic-pull-request

This is a GitHub Action that ensures your PR title matches the Conventional Commits spec.

The typical use case is to use this in combination with a tool like semantic-release to automate releases.

Validation

Examples for valid PR titles:

  • fix: Correct typo.
  • feat: Add support for Node 12.
  • refactor!: Drop support for Node 6.
  • feat(ui): Add Button component.

Note that since PR titles only have a single line, you have to use the ! syntax for breaking changes.

See Conventional Commits for more examples.

Installation

  1. If your goal is to create squashed commits that will be used for automated releases, you'll want to configure your GitHub repository to use the squash & merge strategy and tick the option "Default to PR title for squash merge commits".
  2. Add the action with the following configuration
name: "Lint PR"

on:
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize

jobs:
  main:
    name: Validate PR title
    runs-on: ubuntu-latest
    steps:
      - uses: amannn/action-semantic-pull-request@v4
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Configuration

The action works without configuration, however you can provide options for customization.

The following terminology helps to understand the configuration options:

feat(ui): Add `Button` component.
^    ^    ^
|    |    |__ Subject
|    |_______ Scope
|____________ Type
        with:
          # Configure which types are allowed.
          # Default: https://github.com/commitizen/conventional-commit-types
          types: |
            fix
            feat
          # Configure which scopes are allowed.
          scopes: |
            core
            ui
          # Configure that a scope must always be provided.
          requireScope: true
          # Configure which scopes are disallowed in PR titles. For instance by setting
          # the value below, `chore(release): ...` and `ci(e2e,release): ...` will be rejected.
          disallowScopes: |
            release
          # Configure additional validation for the subject based on a regex.
          # This example ensures the subject doesn't start with an uppercase character.
          subjectPattern: ^(?![A-Z]).+$
          # If `subjectPattern` is configured, you can use this property to override
          # the default error message that is shown when the pattern doesn't match.
          # The variables `subject` and `title` can be used within the message.
          subjectPatternError: |
            The subject "{subject}" found in the pull request title "{title}"
            didn't match the configured pattern. Please ensure that the subject
            doesn't start with an uppercase character.
          # If you use GitHub Enterprise, you can set this to the URL of your server
          githubBaseUrl: https://github.myorg.com/api/v3
          # If the PR contains one of these labels, the validation is skipped.
          # Multiple labels can be separated by newlines.
          # If you want to rerun the validation when labels change, you might want
          # to use the `labeled` and `unlabeled` event triggers in your workflow.
          ignoreLabels: |
            bot
            ignore-semantic-pull-request
          # If you're using a format for the PR title that differs from the traditional Conventional
          # Commits spec, you can use these options to customize the parsing of the type, scope and
          # subject. The `headerPattern` should contain a regex where the capturing groups in parentheses
          # correspond to the parts listed in `headerPatternCorrespondence`.
          # See: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#headerpattern
          headerPattern: '^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$'
          headerPatternCorrespondence: type, scope, subject
          # For work-in-progress PRs you can typically use draft pull requests 
          # from GitHub. However, private repositories on the free plan don't have 
          # this option and therefore this action allows you to opt-in to using the 
          # special "[WIP]" prefix to indicate this state. This will avoid the 
          # validation of the PR title and the pull request checks remain pending.
          # Note that a second check will be reported if this is enabled.
          wip: true

Event triggers

There are two events that can be used as triggers for this action, each with different characteristics:

  1. pull_request_target: This allows the action to be used in a fork-based workflow, where e.g. you want to accept pull requests in a public repository. In this case, the configuration from the main branch of your repository will be used for the check. This means that you need to have this configuration in the main branch for the action to run at all (e.g. it won't run within a PR that adds the action initially). Also if you change the configuration in a PR, the changes will not be reflected for the current PR – only subsequent ones after the changes are in the main branch.
  2. pull_request: This configuration uses the latest configuration that is available in the current branch. It will only work if the branch is based in the repository itself. If this configuration is used and a pull request from a fork is opened, you'll encounter an error as the GitHub token environment parameter is not available. This option is viable if all contributors have write access to the repository.

Legacy configuration

When using "Squash and merge" on a PR with only one commit, GitHub will suggest using that commit message instead of the PR title for the merge commit and it's easy to commit this by mistake. To help out in this situation this action supports two configuration options. However, GitHub has introduced an option to streamline this behaviour, so using that instead should be preferred.

          # If the PR only contains a single commit, the action will validate that
          # it matches the configured pattern.
          validateSingleCommit: true
          # Related to `validateSingleCommit` you can opt-in to validate that the PR
          # title matches a single commit to avoid confusion.
          validateSingleCommitMatchesPrTitle: true
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].