GithubHelp home page GithubHelp logo

deepakputhraya / action-pr-title Goto Github PK

View Code? Open in Web Editor NEW
121.0 2.0 75.0 1006 KB

Github action to enforce Pull Request title conventions

License: MIT License

JavaScript 100.00%
github-actions pull-requests pull-request hacktoberfest pullrequest pullrequests

action-pr-title's Introduction

Branch naming rules

GitHub Actions status

Github action to enforce Pull Request title conventions

Usage

See action.yml

steps:
- uses: deepakputhraya/action-pr-title@master
  with:
    regex: '([a-z])+\/([a-z])+' # Regex the title should match.
    allowed_prefixes: 'feature,fix,JIRA' # title should start with the given prefix
    disallowed_prefixes: 'feat/,hotfix' # title should not start with the given prefix
    prefix_case_sensitive: false # title prefix are case insensitive
    min_length: 5 # Min length of the title
    max_length: 20 # Max length of the title
    github_token: ${{ github.token }} # Default: ${{ github.token }}

Note:

Ensure to add types to the Pull requests webhook event as by default workflows are triggered only for opened, synchronize, or reopened pull request events. Read more about it here.

on:
  pull_request:
    types: [opened, edited, synchronize, reopened]

Triggering the action on anything other than pull_request will cause a failure.

License

The scripts and documentation in this project are released under the MIT License

action-pr-title's People

Contributors

deepakputhraya avatar dependabot[bot] avatar thedaviddias avatar wangxisea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

action-pr-title's Issues

Prefix Error Not Right

It's saying my prefix isn't correct but it is, not sure how to debug or fix it from here

Screen Shot 2020-12-09 at 9 10 21 PM

Regex validation isnt working properly

I have the following workflow

validate-pr-title:
        name: PR Title Validation
        runs-on: ubuntu-latest
        steps:
          - uses: deepakputhraya/action-pr-title@master
            with:
              regex: '((feature|bugfix|hotfix)\/){0,1}(MULE|HUG)-\d+'
              prefix_case_sensitive: true
              github_token: ${{ github.token }}

This is the output of the job:

image

This is what it should have done
image

Why isn't it failing if the PR title does not match the regex?

action-pr-title/index.js

Lines 43 to 47 in 3864beb

const regex = RegExp(core.getInput('regex'));
if (!regex.test(title)) {
core.setFailed(`Pull Request title "${title}" failed to pass match regex - ${regex}`);
return
}

[Feature Request] Add disallowed prefixes

Hi

Thanks for this

In my case I would like to not allow to have PRs that starts with feature/ but just feature is ok.

I dont see a way to setup this with this one.

re-run the action after renaming the PR title does not work

  • Create a PR with bad title
  • Github Action fails
  • Rename PR with good title
  • Re-run Github action
  • Github action fails again on the previous PR title

Only solution I found is to close/open a new PR or kick the build via commit; both are not great.

Update to Node 16

We're using this action in our project and I noticed that Github Actions issues warnings stating that Node 12 does not receive support anymore as of April 2022, see Github Blog.

I think it's as easy as replacing

runs:
  using: 'node12'
  main: 'index.js'

with

runs:
  using: 'node16'
  main: 'index.js'

in action.yml.

Runs only on default branch

This might be more of a github-actions question than an issue with this action. I'm new to github-actions so would appreciate some help :)

This is the yml script that I use but it triggers only on PRs based on the master (default) branch. When I open a PR on a release/... branch, this is not triggered. I assumed that if I don't specifically set a branch under the on: condition, it should work for all branches. Is that not the case?

name: PR Title Check

on:
  pull_request:
    types: [ opened, edited, synchronize, reopened ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Pull Request title rules
        uses: deepakputhraya/[email protected]
        with:
          regex: {redacted}

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.