name: "PR Formatting" on: pull_request_target: types: - opened - reopened - edited permissions: statuses: write pull-requests: write jobs: title-check: name: Title Check runs-on: ubuntu-latest steps: - name: Harden Runner uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 with: egress-policy: audit - name: Check PR Title id: title_check uses: amannn/action-semantic-pull-request@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Comment with changelog hint on failure if: failure() uses: actions/github-script@v7 with: script: | const marker = ''; const error = `${{ steps.title_check.outputs.error_message || steps.title_check.outputs.error || '' }}`.trim(); const details = error ? `\n\n**Error:** ${error}` : '\n\n**Error:** See workflow logs.'; const body = `${marker} **PR title check failed** Please use a Conventional Commit-style prefix (e.g., \`feat:\`, \`fix:\`, \`docs:\`, \`chore:\`). If this change should appear in release notes, ensure the title reflects the correct category.${details}`; const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, }); const existing = comments.find((comment) => comment.body && comment.body.includes(marker)); if (existing) { await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body, }); } else { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body, }); }