GithubHelp home page GithubHelp logo

nivisi / conventional_pull_requests Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.18 MB

โค๏ธโ€๐Ÿฉน A GitHub Action that helps to maintain conventional pull request names.

License: MIT License

JavaScript 100.00%

conventional_pull_requests's Introduction

Conventional Pull Requests version

โค๏ธโ€๐Ÿฉน A GitHub Action that helps to maintain conventional pull request names.

Overview

This GitHub Action designed to automate the validation and correction of Pull Request (PR) titles in collaborative software development environments. This Action helps maintain consistency and clarity in PR naming conventions, ensuring that all PRs adhere to predefined formatting rules.

Checkout this pull request for an example.

Features

  • Validation: Checks if PR titles conform to specified formatting rules.
  • Automatic Correction: Where possible, automatically corrects PR titles to meet the standards.
  • Commenting: Posts a comment on the PR when a correction is made, providing visibility and feedback.

Usage

To use this GitHub Action in your project, set up the workflow file:

  • Create a .github/workflows directory in your repository if it doesn't exist.
  • Add a new YAML file (e.g., conventional-prs.yml) in this directory.
  • Define the workflow to trigger on PR events and run the Validator.

Example

name: Convenitonal Pull Requests

on:
   pull_request:
     types:
      # Configure these types yourself!
      - opened
      - edited
      - reopened
      - synchronize
  
   workflow_dispatch:
  
jobs:
  validate:

    runs-on: ubuntu-latest
  
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Validate PR Name
      uses: nivisi/[email protected]+2
      with:
         # GitHub Access Token
         # Required. Default is ${{ github.token }}
         github-token: ${{ github.token }}
  
         # Message that will be posted as a comment in the PR
         # In case the script finds an issue and will be capable of fixing it.
         # {AUTHOR} will be the author of the PR
         # {DIFF} is a suggested difference (old title vs new title)
         message-to-post: |
             Hey @{AUTHOR} ๐Ÿ‘‹ I'm the PR Bot! ๐Ÿค– I noticed that the title of this Pull Request didn't match the required schema, so I've made a quick fix:

             {DIFF}

Examples

Valid PR Titles

  • fix(ABC-1): Updates the UI of the Search Page: Correct format with type, ticket number, and task description.
  • feat: New screen introduced: Valid format with only type and task description.
  • feat(ABC-5,ABC-10): Something happened: Correct format with multiple ticket numbers.

Invalid PR Titles

Auto-fixable

  • feat (ABC-10): Introduces new feature: Invalid due to space before the colon.
  • fix(ABC-1) : Updates the UI: Invalid due to space after ticket number and before the colon.
  • Feat(ABC-123): Adds feature: Invalid due to uppercase type.
  • feat(abc-123): New feature: Invalid due to lowercase ticket number.
  • feat(123-ABC): Wrong format: Invalid ticket format.
  • feat(ABC-123,abc-456): Multi tickets: Invalid due to lowercase ticket number in the second ticket.

Not auto-fixable

  • : Implemented new algorithm: Invalid due to missing type.
  • feat(): Empty ticket number: Invalid due to empty ticket number.

Contributing

Contributions to improve the Validator GitHub Action are welcome. Feel free to fork the repository, make your changes, and submit a pull request.

TODO

  • Follow more rules from the ruleset
  • Allow to restrict ticket prefixes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.