From a5597bbcde03acf6c4b13e8a60ed48a7c113f56f Mon Sep 17 00:00:00 2001 From: Sven Lito Date: Fri, 8 Aug 2025 17:48:53 +0700 Subject: [PATCH] feat: add semantic PR validation workflow - Validates PR titles against conventional commit standards - Adds helpful comments when titles don't follow format - Auto-deletes comments when titles are fixed - Uses standard GITHUB_TOKEN (no special app setup needed) - Enforces consistency with semantic-release workflow --- .github/workflows/semantic-pr.yml | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/semantic-pr.yml diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml new file mode 100644 index 0000000..48c3aa3 --- /dev/null +++ b/.github/workflows/semantic-pr.yml @@ -0,0 +1,47 @@ +--- +name: Semantic PR + +on: + pull_request: + types: [opened, edited, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + +jobs: + semantic-pr: + name: Validate PR + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Check PR Title + id: lint-pr-title + uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Add PR error comment + uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943 # v2.9.3 + if: always() && (steps.lint-pr-title.outputs.error_message != null) + with: + header: pr-title-lint-error + message: | + We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + + Details: + + ``` + ${{ steps.lint-pr-title.outputs.error_message }} + ``` + + - name: Delete PR error comment + uses: marocchino/sticky-pull-request-comment@d2ad0de260ae8b0235ce059e63f2949ba9e05943 # v2.9.3 + if: ${{ steps.lint-pr-title.outputs.error_message == null }} + with: + header: pr-title-lint-error + delete: true \ No newline at end of file