From 9588d0f560d0985a68f016ee74e5c53e99b2ee3a Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 17:22:53 +0200 Subject: [PATCH 01/20] update checkout version --- .github/workflows/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 3f8cfd7a..8eeaffcf 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -12,7 +12,7 @@ jobs: pull-requests: write steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install R uses: r-lib/actions/setup-r@v2 From 020c9e85e5f85f61e091853c3f4fcce762771edc Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 17:38:29 +0200 Subject: [PATCH 02/20] no CNAME --- .github/workflows/preview.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 8eeaffcf..27d8cc78 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -27,6 +27,10 @@ jobs: source ~/.bashrc rv sync + - name: Don't publish CNAME for preview + run: | + rm CNAME + - name: Set up Quarto environment uses: quarto-dev/quarto-actions/setup@v2 From dfa1e7062c6dbbc944a9e70e3b776c81f9a475c8 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 17:56:22 +0200 Subject: [PATCH 03/20] with docker --- .github/workflows/preview.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 27d8cc78..0c2e2bab 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -10,14 +10,18 @@ jobs: permissions: contents: read pull-requests: write + container: + image: inseefrlab/onyxia-r-minimal:4.6.0 + volumes: + - /tmp/data:/data steps: - name: Check out repository uses: actions/checkout@v6 - - name: Install R - uses: r-lib/actions/setup-r@v2 - with: - r-version: '4.6' + # - name: Install R + # uses: r-lib/actions/setup-r@v2 + # with: + # r-version: '4.6' - name: Install dependencies run: | From 78e275e41a324e16b90d44d2c661f4eaa8c5b165 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 17:57:26 +0200 Subject: [PATCH 04/20] typo tag container --- .github/workflows/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 0c2e2bab..b5e0f665 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -11,7 +11,7 @@ jobs: contents: read pull-requests: write container: - image: inseefrlab/onyxia-r-minimal:4.6.0 + image: inseefrlab/onyxia-r-minimal:r4.6.0 volumes: - /tmp/data:/data steps: From 5cf395d0ada35313c1af786eaa239292208dc6c6 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 18:03:40 +0200 Subject: [PATCH 05/20] with admin for container --- .github/workflows/preview.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index b5e0f665..4c0a6885 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -12,8 +12,7 @@ jobs: pull-requests: write container: image: inseefrlab/onyxia-r-minimal:r4.6.0 - volumes: - - /tmp/data:/data + options: --user root # Force root user steps: - name: Check out repository uses: actions/checkout@v6 From eff90059ca8253922e795e4dadd85e64b4a2dc1c Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 20:18:27 +0200 Subject: [PATCH 06/20] no source --- .github/workflows/preview.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 4c0a6885..cf49aafe 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -26,8 +26,8 @@ jobs: 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 rv sync - name: Don't publish CNAME for preview From 310889488b4b7c15cce8ab4afc697b34e6638d62 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:02:14 +0200 Subject: [PATCH 07/20] fix permissions bot --- .github/workflows/preview.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index cf49aafe..17edeeba 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -8,7 +8,7 @@ jobs: build-preview: runs-on: ubuntu-latest permissions: - contents: read + contents: write pull-requests: write container: image: inseefrlab/onyxia-r-minimal:r4.6.0 @@ -17,11 +17,6 @@ jobs: - name: Check out repository uses: actions/checkout@v6 - # - name: Install R - # uses: r-lib/actions/setup-r@v2 - # with: - # r-version: '4.6' - - name: Install dependencies run: | sudo ./docker/dependencies.sh From 2a207d3db6584fd6351f6cf56dbeda0f31b09355 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:04:53 +0200 Subject: [PATCH 08/20] with concurrency --- .github/workflows/preview.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 17edeeba..30eb7539 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -4,12 +4,14 @@ on: name: Quarto Preview +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + jobs: build-preview: runs-on: ubuntu-latest permissions: contents: write - pull-requests: write container: image: inseefrlab/onyxia-r-minimal:r4.6.0 options: --user root # Force root user From c52adad974608ae59102dfcfb64ca46e8e338f23 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:08:07 +0200 Subject: [PATCH 09/20] update render site --- .github/workflows/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 30eb7539..ca6cc22b 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -41,7 +41,7 @@ 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 From d091de6ded25b087d4611b939ef215f4d21e9b6a Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:16:11 +0200 Subject: [PATCH 10/20] update concurrency --- .github/workflows/preview.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index ca6cc22b..c6f7ca32 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -5,7 +5,8 @@ on: name: Quarto Preview concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }} # Unique Quarto Preview per PR + cancel-in-progress: true jobs: build-preview: From d4453bf1ce067c803120eaa4256770b9de2c8673 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:23:03 +0200 Subject: [PATCH 11/20] update permissions to write comment --- .github/workflows/preview.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index c6f7ca32..355fbaa6 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -12,7 +12,8 @@ jobs: build-preview: runs-on: ubuntu-latest permissions: - contents: 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 From 952860a680b10c0b6f58c9e418ab0d5d112d7bda Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:25:59 +0200 Subject: [PATCH 12/20] with delete preview when closed --- .github/workflows/preview.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 355fbaa6..47dae5fe 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -10,6 +10,7 @@ concurrency: jobs: build-preview: + if: github.event.action != 'closed' # If closing the PR, no publishing runs-on: ubuntu-latest permissions: contents: write # For pushing to gh-pages branch @@ -59,3 +60,30 @@ jobs: repo: context.repo.repo, body: `🔍 Preview deployed! View it here: [PR #${pr_number} Preview](${preview_url})` }); + +# For this workflow only + delete-preview: + if: github.event.action == 'closed' # Only run when PR is closed + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 # To enable full access to Git repo + ref: ${{ github.event.pull_request.head.ref }} # Reference of the commit to checkout to. To ensure it's the one of the PR + repository: ${{github.event.pull_request.head.repo.full_name}} # Reference to the branch to checkout to. Useful with PR from forks + + - name: Remove preview + id: remove-preview + uses: rossjrw/pr-preview-action@v1.8.1 + with: + action: remove + token: ${{ secrets.DEPLOY_GH_PAGES_TOKEN }} # Uses a token to allow preview from forks + + - name: Comment PR that preview was removed + uses: marocchino/sticky-pull-request-comment@v3 + with: + header: pr-preview + message: | + Preview removed because the pull request was closed. + ${{ steps.remove-preview.outputs.action-start-time }} \ No newline at end of file From 5805076b01176b5174f9c08a369f230aba7cf121 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:49:08 +0200 Subject: [PATCH 13/20] triggered when PR is closed --- .github/workflows/preview.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 47dae5fe..517d7a69 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -1,5 +1,10 @@ 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 From c69ee03cca77545a60958ae508a9cee6ff93014b Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:51:51 +0200 Subject: [PATCH 14/20] update comment to sticky comment - to avoid multiple comment --- .github/workflows/preview.yaml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 517d7a69..5c7aa9f3 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -53,18 +53,14 @@ jobs: 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: - script: | - const pr_number = context.issue.number; - const preview_url = `https://${{ github.repository_owner }}.github.io/utilitR/previews/pr-${pr_number}/`; - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `🔍 Preview deployed! View it here: [PR #${pr_number} Preview](${preview_url})` - }); + header: pr-preview + message: | + :rocket: View preview at
${{ steps.deploy-preview.outputs.preview-url }}
+
Built to branch gh-pages at ${{ steps.deploy-preview.outputs.action-start-time }}.
Preview will be ready when the GitHub Pages deployment is complete.
+ # For this workflow only delete-preview: From 31f64deefc4711abbb6e41e56b7aa2f72c3eeeb2 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Wed, 17 Jun 2026 22:55:33 +0200 Subject: [PATCH 15/20] no mc and lib dependancies --- .github/workflows/preview.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 5c7aa9f3..d23ea808 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -29,7 +29,7 @@ jobs: - name: Install dependencies run: | - sudo ./docker/dependencies.sh + # sudo ./docker/dependencies.sh curl -sSL https://raw.githubusercontent.com/A2-ai/rv/refs/heads/main/scripts/install.sh | bash export PATH="$HOME/.local/bin:$PATH" # Use $HOME instead of ~ for reliability . ~/.bashrc From 91dc9c5886e9568e6b23f61fe380e96923a66120 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Thu, 18 Jun 2026 09:54:00 +0200 Subject: [PATCH 16/20] update token permissions and rm checkout --- .github/workflows/preview.yaml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index d23ea808..ac589db4 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -32,7 +32,7 @@ jobs: # sudo ./docker/dependencies.sh curl -sSL https://raw.githubusercontent.com/A2-ai/rv/refs/heads/main/scripts/install.sh | bash export PATH="$HOME/.local/bin:$PATH" # Use $HOME instead of ~ for reliability - . ~/.bashrc + . ~/.bashrc # no source command for this container, so use . instead rv sync - name: Don't publish CNAME for preview @@ -64,22 +64,23 @@ jobs: # For this workflow only delete-preview: - if: github.event.action == 'closed' # Only run when PR is closed + if: github.event.action == 'closed' runs-on: ubuntu-latest + permissions: + contents: write # Required for gh-pages pushes steps: - - name: Check out repository - uses: actions/checkout@v6 - with: - fetch-depth: 0 # To enable full access to Git repo - ref: ${{ github.event.pull_request.head.ref }} # Reference of the commit to checkout to. To ensure it's the one of the PR - repository: ${{github.event.pull_request.head.repo.full_name}} # Reference to the branch to checkout to. Useful with PR from forks - - name: Remove preview - id: remove-preview uses: rossjrw/pr-preview-action@v1.8.1 with: action: remove - token: ${{ secrets.DEPLOY_GH_PAGES_TOKEN }} # Uses a token to allow preview from forks + token: ${{ secrets.GITHUB_TOKEN }} + deploy-repository: ${{ github.repository }} + preview-branch: gh-pages + umbrella-dir: previews # Match your deploy dir (e.g., "previews/pr-1") + env: + DEPLOY_REPO: ${{ github.repository }} + DEPLOY_BRANCH: gh-pages + DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Comment PR that preview was removed uses: marocchino/sticky-pull-request-comment@v3 From 71d587a191ab04d90c1e604eccc8315158e00935 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Thu, 18 Jun 2026 09:57:57 +0200 Subject: [PATCH 17/20] fix --- .github/workflows/preview.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index ac589db4..c87642a6 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -64,23 +64,24 @@ jobs: # For this workflow only delete-preview: - if: github.event.action == 'closed' + if: github.event.action == 'closed' # Only run when PR is closed runs-on: ubuntu-latest permissions: contents: write # Required for gh-pages pushes steps: + - name: Check out repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 # To enable full access to Git repo + ref: ${{ github.event.pull_request.head.ref }} # Reference of the commit to checkout to. To ensure it's the one of the PR + repository: ${{github.event.pull_request.head.repo.full_name}} # Reference to the branch to checkout to. Useful with PR from forks + - name: Remove preview + id: remove-preview uses: rossjrw/pr-preview-action@v1.8.1 with: action: remove - token: ${{ secrets.GITHUB_TOKEN }} - deploy-repository: ${{ github.repository }} - preview-branch: gh-pages - umbrella-dir: previews # Match your deploy dir (e.g., "previews/pr-1") - env: - DEPLOY_REPO: ${{ github.repository }} - DEPLOY_BRANCH: gh-pages - DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Comment PR that preview was removed uses: marocchino/sticky-pull-request-comment@v3 From 4c5ba7e4e0debee8cdeb49950ee7f1a5aa75851b Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Thu, 18 Jun 2026 10:01:44 +0200 Subject: [PATCH 18/20] fix sticky comment --- .github/workflows/preview.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index c87642a6..650543bc 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -68,6 +68,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write # Required for gh-pages pushes + pull-requests: write # Required to comment PR steps: - name: Check out repository uses: actions/checkout@v6 From 68601c07d9b8d775add6644010f6769cd0db758a Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Thu, 18 Jun 2026 10:16:27 +0200 Subject: [PATCH 19/20] with correct dir to delete previews --- .github/workflows/preview.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 650543bc..9647bb6a 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -82,6 +82,7 @@ jobs: uses: rossjrw/pr-preview-action@v1.8.1 with: action: remove + umbrella-dir: previews # <-- Match your deploy directory token: ${{ secrets.GITHUB_TOKEN }} - name: Comment PR that preview was removed From 81f62ab81adf7a4658bf989448bd21189bb767c6 Mon Sep 17 00:00:00 2001 From: Nik <192305627+ntoulemonde@users.noreply.github.com> Date: Thu, 18 Jun 2026 10:23:00 +0200 Subject: [PATCH 20/20] typos comment previews --- .github/workflows/preview.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 9647bb6a..3b2075af 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -29,7 +29,6 @@ jobs: - 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="$HOME/.local/bin:$PATH" # Use $HOME instead of ~ for reliability . ~/.bashrc # no source command for this container, so use . instead @@ -82,7 +81,7 @@ jobs: uses: rossjrw/pr-preview-action@v1.8.1 with: action: remove - umbrella-dir: previews # <-- Match your deploy directory + umbrella-dir: previews token: ${{ secrets.GITHUB_TOKEN }} - name: Comment PR that preview was removed