pr writer fixes

This commit is contained in:
Arthur Tazhitdinov 2026-02-01 21:56:20 +03:00
parent 9db4408750
commit 6297189e6f
2 changed files with 167 additions and 114 deletions

View File

@ -6,10 +6,13 @@ on:
- opened - opened
- reopened - reopened
- edited - edited
- synchronize
permissions: permissions:
contents: read
statuses: write statuses: write
pull-requests: write pull-requests: write
issues: write
jobs: jobs:
title-check: title-check:
@ -25,11 +28,11 @@ jobs:
id: title_check id: title_check
uses: amannn/action-semantic-pull-request@v6 uses: amannn/action-semantic-pull-request@v6
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ github.token }}
- name: Comment with changelog hint on failure - name: Comment with changelog hint on failure
if: failure() if: failure()
uses: actions/github-script@v7 uses: actions/github-script@v8
with: with:
script: | script: |
const marker = '<!-- pr-title-check -->'; const marker = '<!-- pr-title-check -->';
@ -46,8 +49,11 @@ If this change should appear in release notes, ensure the title reflects the cor
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
issue_number: context.issue.number, issue_number: context.issue.number,
per_page: 100,
}); });
const existing = comments.find((comment) => comment.body && comment.body.includes(marker));
const existing = comments.find((comment) => (comment.body || "").includes(marker));
if (existing) { if (existing) {
await github.rest.issues.updateComment({ await github.rest.issues.updateComment({
owner: context.repo.owner, owner: context.repo.owner,
@ -63,3 +69,31 @@ If this change should appear in release notes, ensure the title reflects the cor
body, body,
}); });
} }
- name: Remove failure comment on success
if: success()
uses: actions/github-script@v8
with:
script: |
const marker = '<!-- pr-title-check -->';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});
const existing = comments.find((comment) => (comment.body || "").includes(marker));
if (!existing) {
core.info("No previous PR title failure comment found.");
return;
}
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
});
core.info(`Deleted previous failure comment id=${existing.id}`);

View File

@ -1,4 +1,23 @@
comment_firmware: name: PR writes (label + comment)
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
label:
runs-on: ubuntu-latest
steps:
# Safe: labeler reads files from the base repo by default in pull_request_target context.
# Do NOT checkout PR head.
- uses: actions/labeler@v5
comment_firmware:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Find the matching CI run for this PR SHA - name: Find the matching CI run for this PR SHA