diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml
index 3f8cfd7a..3b2075af 100644
--- a/.github/workflows/preview.yaml
+++ b/.github/workflows/preview.yaml
@@ -1,32 +1,43 @@
on:
pull_request:
+ types:
+ - opened
+ - reopened
+ - synchronize # When the ref of the branch is updated (= commit to the branch to merge)
+ - closed # Including closed to remove preview when PR is closed.
branches: main
name: Quarto Preview
+concurrency:
+ group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }} # Unique Quarto Preview per PR
+ cancel-in-progress: true
+
jobs:
build-preview:
+ if: github.event.action != 'closed' # If closing the PR, no publishing
runs-on: ubuntu-latest
permissions:
- contents: read
- pull-requests: write
+ contents: write # For pushing to gh-pages branch
+ pull-requests: write # For permissions to write comments on PRs
+ container:
+ image: inseefrlab/onyxia-r-minimal:r4.6.0
+ options: --user root # Force root user
steps:
- name: Check out repository
- uses: actions/checkout@v4
-
- - name: Install R
- uses: r-lib/actions/setup-r@v2
- with:
- r-version: '4.6'
+ uses: actions/checkout@v6
- name: Install dependencies
run: |
- sudo ./docker/dependencies.sh
curl -sSL https://raw.githubusercontent.com/A2-ai/rv/refs/heads/main/scripts/install.sh | bash
- export PATH="~/.local/bin:$PATH"
- source ~/.bashrc
+ export PATH="$HOME/.local/bin:$PATH" # Use $HOME instead of ~ for reliability
+ . ~/.bashrc # no source command for this container, so use . instead
rv sync
+ - name: Don't publish CNAME for preview
+ run: |
+ rm CNAME
+
- name: Set up Quarto environment
uses: quarto-dev/quarto-actions/setup@v2
@@ -37,19 +48,46 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: ./_site
+ publish_dir: ./_public
destination_dir: previews/pr-${{ github.event.pull_request.number }}
keep_files: true
- - name: Comment PR with preview link
- uses: actions/github-script@v7
+ - name: Comment PR (custom)
+ uses: marocchino/sticky-pull-request-comment@v3
+ with:
+ header: pr-preview
+ message: |
+ :rocket: View preview at
${{ steps.deploy-preview.outputs.preview-url }}
+