Skip to content

Commit

Permalink
ci[pr-preview]: in header of preview site add link back to pr
Browse files Browse the repository at this point in the history
  • Loading branch information
f-hollow committed Dec 26, 2024
1 parent 32b3d18 commit 6d88bde
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/pr-build-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ jobs:
with:
submodules: recursive

- name: Extract PR URL
id: get-pr-url
run: |
PR_URL=$(jq -r '.pull_request.html_url' "$GITHUB_EVENT_PATH")
echo "PR_URL=$PR_URL" >> $GITHUB_ENV
PR_LINK_TEXT=${PR_URL#https://}
echo "PR_LINK_TEXT=$PR_LINK_TEXT" >> $GITHUB_ENV
- name: Append preview snippet to header file
run: |
PREVIEW_HTML="<p style='color: rgba(var(--color-primary-600), 1); text-align: center;'>
This site is a preview for <a href='${{ env.PR_URL }}' style='text-decoration: underline;'>${{ env.PR_LINK_TEXT }}</a>
</p>"
echo "$PREVIEW_HTML" >> layouts/partials/header/basic.html
- name: Build website with Hugo
env:
# For maximum backward compatibility with Hugo modules
Expand Down

0 comments on commit 6d88bde

Please sign in to comment.