Skip to content

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

License

Notifications You must be signed in to change notification settings

saurabharch/action-rollout-semantic-pull-request

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

🎬 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.

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published