Skip to content

Commit a5d0726

Browse files
mesh-2816: fix pr-lint
1 parent 1806e54 commit a5d0726

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

.github/workflows/pr-lint.yaml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: PR Quality Check
22
on: pull_request
3+
permissions:
4+
pull-requests: write
35
jobs:
46
link-ticket:
57
runs-on: ubuntu-latest
@@ -20,10 +22,33 @@ jobs:
2022
2123
- name: Comment on PR
2224
if: contains(github.event.pull_request.head.ref, 'apm-') || contains(github.event.pull_request.head.ref, 'APM-') || contains(github.event.pull_request.head.ref, 'mesh-') || contains(github.event.pull_request.head.ref, 'MESH-') || contains(github.event.pull_request.head.ref, 'mesh2cloud-') || contains(github.event.pull_request.head.ref, 'MESH2CLOUD-') || contains(github.event.pull_request.head.ref, 'spii-') || contains(github.event.pull_request.head.ref, 'SPII-') || contains(github.event.pull_request.head.ref, 'spinecore-') || contains(github.event.pull_request.head.ref, 'SPINECORE-')
23-
uses: unsplash/comment-on-pr@master
24-
env:
25-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
uses: actions/github-script@v7
2626
with:
27-
msg: |
28-
This branch is work on a ticket in the NHS Digital AMB JIRA Project. Here's a handy link to the ticket:
29-
# [${{ env.TICKET_NAME }}](https://jira.digital.nhs.uk/browse/${{ env.TICKET_NAME}})
27+
script: |
28+
const owner = context.repo.owner;
29+
const repo = context.repo.repo;
30+
const issue_number = context.payload.pull_request.number;
31+
const ticket = process.env.TICKET_NAME;
32+
const message = `This branch is work on a ticket in the NHS Digital AMB JIRA Project. Here's a handy link to the ticket:\n# [${ticket}](https://jira.digital.nhs.uk/browse/${ticket})`;
33+
34+
const { data: comments } = await github.rest.issues.listComments({
35+
owner,
36+
repo,
37+
issue_number,
38+
per_page: 100,
39+
});
40+
41+
const existing = comments.find((comment) =>
42+
comment.body && comment.body.includes(`https://jira.digital.nhs.uk/browse/${ticket}`)
43+
);
44+
45+
if (!existing) {
46+
await github.rest.issues.createComment({
47+
owner,
48+
repo,
49+
issue_number,
50+
body: message,
51+
});
52+
}
53+
env:
54+
TICKET_NAME: ${{ env.TICKET_NAME }}

0 commit comments

Comments
 (0)