-
Notifications
You must be signed in to change notification settings - Fork 47
40 lines (35 loc) · 1.38 KB
/
test-link.yml
File metadata and controls
40 lines (35 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Update PR Description
on:
pull_request_target: # use this trigger to run on external pull requests too
types: [opened, synchronize]
jobs:
update-description:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Update PR description
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const owner = context.payload.pull_request.head.repo.owner.login;
const repo = context.payload.pull_request.head.repo.name;
const commit = context.payload.pull_request.head.sha;
const link = `https://raw.githack.com/${owner}/${repo}/${commit}/dev/web-demo.html`;
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
if (!pullRequest.body.includes(link)) {
const updatedBody = `${pullRequest.body}\n\n[Open web-demo @ ${commit}](${link})`;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: updatedBody,
});
}