Skip to content

Commit 269b210

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

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/link-comment.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
github-token: ${{ secrets.GH_TOKEN }}
18+
script: |
19+
const prNumber = context.payload.pull_request.number;
20+
const owner = context.payload.pull_request.head.repo.owner.login;
21+
const repo = context.payload.pull_request.head.repo.name;
22+
const commit = context.payload.pull_request.head.sha;
23+
const link = `https://raw.githack.com/${owner}/${repo}/${commit}/kitchen-sink.html`;
24+
25+
const { data: pullRequest } = await github.rest.pulls.get({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
pull_number: prNumber,
29+
});
30+
31+
if (!pullRequest.body.includes(link)) {
32+
const updatedBody = `${pullRequest.body}\n\n[View the changes](${link})`;
33+
34+
await github.rest.pulls.update({
35+
owner: context.repo.owner,
36+
repo: context.repo.repo,
37+
pull_number: prNumber,
38+
body: updatedBody,
39+
});
40+
}

0 commit comments

Comments
 (0)