Skip to content

Commit f933e16

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

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/link-comment.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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: Set up GitHub token
15+
run: echo "GH_TOKEN=${{ secrets.GH_TOKEN }}" >> $GITHUB_ENV
16+
17+
- name: Update PR description
18+
uses: actions/github-script@v6
19+
with:
20+
github-token: ${{ secrets.GH_TOKEN }}
21+
script: |
22+
const prNumber = context.payload.pull_request.number;
23+
const owner = context.payload.pull_request.head.repo.owner.login;
24+
const repo = context.payload.pull_request.head.repo.name;
25+
const commit = context.payload.pull_request.head.sha;
26+
const link = `https://raw.githack.com/${owner}/${repo}/${commit}/kitchen-sink.html`;
27+
28+
const { data: pullRequest } = await github.rest.pulls.get({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
pull_number: prNumber,
32+
});
33+
34+
if (!pullRequest.body.includes(link)) {
35+
const updatedBody = `${pullRequest.body}\n\n[View the changes](${link})`;
36+
37+
await github.rest.pulls.update({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
pull_number: prNumber,
41+
body: updatedBody,
42+
});
43+
}

0 commit comments

Comments
 (0)