From 6d88bde2ad0ab42a0689da1e14685190df7689c4 Mon Sep 17 00:00:00 2001 From: "kirill.chalov" Date: Thu, 26 Dec 2024 16:53:35 +0800 Subject: [PATCH] ci[pr-preview]: in header of preview site add link back to pr --- .github/workflows/pr-build-preview.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/pr-build-preview.yml b/.github/workflows/pr-build-preview.yml index 9c634227..22087f9d 100644 --- a/.github/workflows/pr-build-preview.yml +++ b/.github/workflows/pr-build-preview.yml @@ -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="

+ This site is a preview for ${{ env.PR_LINK_TEXT }} +

" + echo "$PREVIEW_HTML" >> layouts/partials/header/basic.html + - name: Build website with Hugo env: # For maximum backward compatibility with Hugo modules