Skip to content

Commit

Permalink
Trying different style
Browse files Browse the repository at this point in the history
  • Loading branch information
nguy8tri committed Sep 17, 2024
1 parent 04b829e commit c8a095f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/pr-artifacts-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,26 @@ jobs:
with:
script: |
const prNumber = process.env.PR_NUMBER;
prFooter = `# Artifacts for PR #${prNumber}\n\n`;
prFooter += `- [Coverage Artifact](https://uwcubesat.github.io/found/${prNumber}/merge/coverage)\n`;
prFooter += `- [Doxygen Artifact](https://uwcubesat.github.io/found/${prNumber}/merge/doxygen)\n`;
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,
});
console.log(`Body: ${pr.body}`);
console.log(`Footer: ${prFooter}`);
console.log(`pr.body.includes(prFooter): ${pr.body.includes(prFooter)}`);
if (pr.body.includes(prFooter)) {
// Check if both artifact links are already present in the PR body
if (pr.body.includes(artifactLinks.trim())) {
console.log('PR description already has documentation artifacts');
} else {
const newPrBody = `# Artifacts for PR #${prNumber}\n\n${artifactLinks.trim()}\n\n${pr.body}`;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
body: `# PR Description\n\n${pr.body}\n${prFooter}`,
body: newPrBody,
});
console.log('PR description updated with documentation artifacts');
}

0 comments on commit c8a095f

Please sign in to comment.