Coder Social home page Coder Social logo

saurabharch / action-rollout-semantic-pull-request Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 358 KB

GitHub Action to validate that PR titles in saurabharch/rollout match rollout version of the Conventional Commits spec

License: MIT License

Shell 2.19% JavaScript 97.81%

action-rollout-semantic-pull-request's Introduction

🎬 action-rollout-semantic-pull-request

GitHub Action to validate that PR titles in saueabharch/rollout match rollout version of the Conventional Commits spec.

🏗️Setup

  1. Make a .github/workflows dir in your repo.
  2. Create .github/workflows/validate-pr-title.yml containing:
name: Validate PR title

on:
  pull_request:
    types:
      - opened
      - edited
      - synchronize

jobs:
  validate_pr_title:
    name: Validate PR title
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Validate PR title
        uses: saurabharch/action-rollout-semantic-pull-request@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Warning: Only the pull_request event may be used as a workflow trigger.

  1. Store GITHUB_TOKEN as a repo secret. Required for fetching the latest PR title on update.

Output

On validation failure, this action will populate the validation_issues output. You can use this output in subsequent steps, e.g. to send the validation issue as a comment on the pull request.

📰

Output usage example
name: Validate PR title

on:
  pull_request:
    types:
      - opened
      - edited
      - synchronize

jobs:
  main:
    name: Validate PR title
    runs-on: ubuntu-latest
    steps:
      - uses: saurabharch/action-rollout-semantic-pull-request@v1
        id: validate_pr_title
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: marocchino/sticky-pull-request-comment@v2
        if: always() # ensure workflow continues executing despite validation errors
        with:
          header: pr_title_failed_validation
          message: |
            Thank you for your contribution!

            PR titles in this repo follow our version of the Conventional Commits spec.
            This allows us to automatically generate the changelog for the next release.
            Therefore, we ask you to adjust your PR title to solve the issue(s) below:

            ```
            ${{ steps.validate_pr_title.outputs.validation_issues }}
            ```

      - if: ${{ steps.validate_pr_title.outputs.validation_issues == null }}
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          header: pr_title_failed_validation
          delete: true # delete prior comment when issue is resolved

Release

git tag -m "Release v1.x.x" v1.x.x
git push --follow-tags

Author

© 2022 Saurabh Kashyap

License

Distributed under the MIT License.

action-rollout-semantic-pull-request's People

Contributors

saurabharch avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.