Open JoshuaKGoldberg opened 1 year ago
Hey Josh 👋
I've been using action-semantic-pull-request for this exact purpose for a while now, and I found it working pretty well. It cannot automatically change the PR title, but it has a pretty helpful error message, and can be used in combination with sticky-pull-request-comment to post the error as a PR comment.
Do you think it would worth a try? I'm open to create a draft PR for it.
Heya! 👋
This is interesting! I hadn't seen those two actions - love that so many folks are using them. This is great. Thanks for showing me them. 😄
I'd love to see an example repo that uses the two of them together. Especially one that can show a PR with the comment. Do you have a reference handy, or could you make one?
Note that long-term I'm planning on making a generalized "GitHub Linter" that could do this. But that's not blocking at all, we can get this in in the interim.
Of course, there you go: https://github.com/Lehoczky/pipeline-practices/pull/24
I'm using the example from the semantic pr action's REAMDE:
name: "Semantic PR title"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
permissions:
pull-requests: write
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@v2
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/) and it looks like your proposed title needs to be adjusted.
Details:
${{ steps.lint_pr_title.outputs.error_message }}
```
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
https://github.com/Lehoczky/pipeline-practices/blob/master/.github/workflows/semantic-pr-title.yml
And the best thing is, if I change the PR title to follow the conventions, the PR comment automatically vanishes.
Cool that looks like a great start, thanks @Lehoczky! https://github.com/marocchino/sticky-pull-request-comment is fantastic for doing so much of what this needs. We can always file the "also suggest a better title" feature point as a followup. I'm up for taking that in as a PR if you're up for sending one. 🚀
A few quick suggestions:
fix: Update package.json
and fix: fix: update package.json
. If that's easy to do & straightforward, it'd be nice - otherwise it's fine as a followup```
code block include the full list of details. Can that be in regular markdown outside the code block instead?
Bug Report Checklist
main
branch of the repository.Overview
I see a lot of PRs from first time / early contributors with titles like
Fixes #...
orFeature: Do Some Thing
. It would be nice if an action could post a comment saying "hey, that title looks off, please make it adhere to (link to conventional spec)." And even better if the action can auto-apply those changes for people!Additional Info
No response