diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 9945c493b..986f88ad4 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -32,6 +32,7 @@ jobs: NOT_CRAN: "true" permissions: contents: write + pull-requests: write steps: - uses: actions/checkout@v7 @@ -62,8 +63,11 @@ jobs: Sys.setenv(PKGDOWN_DEV_MODE = "unreleased") } + preview <- paste0(pkg$meta$url, "/pr/", pr_number) + cat(paste0("PREVIEW_URL=", preview, "\n"), file = Sys.getenv("GITHUB_ENV"), append = TRUE) + override <- list( - url = paste0(pkg$meta$url, "/pr/", pr_number), + url = preview, template = list( params = list(noindex = TRUE) ) @@ -91,6 +95,16 @@ jobs: clean: true force: false + - name: Comment preview link + if: > + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + uses: marocchino/sticky-pull-request-comment@v2 + with: + message: | + Preview: ${{ env.PREVIEW_URL }} + Built from ${{ github.event.pull_request.head.sha }} + - name: Deploy site if: github.event_name != 'pull_request' uses: JamesIves/github-pages-deploy-action@v4 @@ -111,6 +125,7 @@ jobs: permissions: contents: write + pull-requests: write steps: - uses: actions/checkout@v7 @@ -133,3 +148,9 @@ jobs: git commit -m "Remove pkgdown preview for PR #$PR_NUMBER" git pull --rebase origin gh-pages git push origin HEAD:gh-pages + + - name: Hide preview comment + uses: marocchino/sticky-pull-request-comment@v2 + with: + hide: true + hide_classify: OUTDATED