Files
streamyfin/.github/workflows/pr-title.yml
Gauvain 04be0bf796 ci(pr-title): use pull_request_target and guard the cleanup with success()
pull_request_target gives fork PRs a write token so the title-lint sticky
comment posts for external contributors (the workflow only reads the title and
comments — it never checks out or runs PR code). Also AND the delete-comment
step with success() so a crashed lint run (not a lint violation) can't leave
error_message unset and wrongly delete the error comment.
2026-07-07 00:13:41 +02:00

52 lines
1.9 KiB
YAML

name: 📝 PR Title
# pull_request_target so fork PRs get a write token — this workflow only reads
# the PR title and posts/updates a sticky comment; it never checks out or runs
# PR code, so it is not exposed to the usual _target code-execution risk.
on:
pull_request_target:
types: [opened, edited, synchronize, reopened]
branches: [develop, master]
permissions:
contents: read
# Key on the PR number, not github.ref: under pull_request_target github.ref is
# the base branch (shared by every PR), which would collapse all PRs into one
# group and cross-cancel their title checks.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
validate_pr_title:
name: "📝 Validate PR Title"
runs-on: ubuntu-26.04
permissions:
pull-requests: write
contents: read
steps:
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
**Error details:**
```
${{ steps.lint_pr_title.outputs.error_message }}
```
- if: ${{ success() && steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4
with:
header: pr-title-lint-error
delete: true