-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (40 loc) · 1.72 KB
/
pr-artifacts-link.yml
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
41
42
43
44
45
46
47
48
name: Update PR Description with Build Artifacts
on:
pull_request:
branches: [ "main" ]
types: [opened, edited, synchronize]
jobs:
update-description:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get PR number
id: get-pr-number
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
- name: Update PR description
uses: actions/github-script@v7
with:
script: |
const prNumber = process.env.PR_NUMBER;
const prFooter = `# Artifacts for PR #${prNumber} (DO NOT CHANGE)`;
const artifactLinks = `- [Coverage Artifact](https://uwcubesat.github.io/found/${prNumber}/merge/coverage)\n`
+ `- [Doxygen Artifact](https://uwcubesat.github.io/found/${prNumber}/merge/doxygen)\n`;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
// Check if both artifact links are already present in the PR body
if (pr.body.includes("Artifacts for PR")) {
console.log('PR description already has documentation artifacts');
} else {
const newPrBody = `# Description\n${pr.body}\n\n${prFooter}\n${artifactLinks.trim()}`;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: newPrBody,
});
console.log('PR description updated with documentation artifacts');
}