Skip to content

Commit 255409b

Browse files
committed
workflow to add raw.githack link to pull requests
1 parent 1098e53 commit 255409b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/link-comment.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Update PR Description
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
7+
jobs:
8+
update-description:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v2
13+
14+
- name: Update PR description
15+
uses: actions/github-script@v6
16+
with:
17+
script: |
18+
const prNumber = context.payload.pull_request.number;
19+
const owner = context.payload.pull_request.head.repo.owner.login;
20+
const repo = context.payload.pull_request.head.repo.name;
21+
const commit = context.payload.pull_request.head.sha;
22+
const link = `https://raw.githack.com/${owner}/${repo}/${commit}/kitchen-sink.html`;
23+
24+
const { data: pullRequest } = await github.rest.pulls.get({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
pull_number: prNumber,
28+
});
29+
30+
if (!pullRequest.body.includes(link)) {
31+
const updatedBody = `${pullRequest.body}\n\n[View the changes](${link})`;
32+
33+
await github.rest.pulls.update({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
pull_number: prNumber,
37+
body: updatedBody,
38+
});
39+
}

0 commit comments

Comments
 (0)