-
Notifications
You must be signed in to change notification settings - Fork 57
78 lines (75 loc) · 2.75 KB
/
bookdown-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
on:
push:
branches-ignore:
- master
- main
pull_request:
branches:
- main
- master
name: Preview website
jobs:
build:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: ubuntu-latest
container: inseefrlab/utilitr:latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Configure safe repository
run: |
git config --global --add safe.directory /__w/utilitR/utilitR
- name: Set RENV_PATHS_ROOT
shell: bash
run: |
echo "RENV_PATHS_ROOT=${{ runner.temp }}/renv" >> $GITHUB_ENV
- name: Install and activate renv
run: |
install.packages("yaml")
install.packages("renv")
renv::status()
renv::activate()
shell: Rscript {0}
- name: Get R and OS version
id: get-version
run: |
cat("##[set-output name=os-version;]", sessionInfo()$running, "\n", sep = "")
cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "")
shell: Rscript {0}
- name: Restore Renv package cache
uses: actions/cache@v4
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }}
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-
env:
GITHUB_PAT: ${{ secrets.PAT }}
- name: Render Book
run: |
quarto render
- uses: actions/upload-artifact@v4
with:
name: _public
path: _public/
retention-days: 5
- name: Install npm
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Deploy to Netlify
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
# NETLIFY_AUTH_TOKEN and NETLIFY_SITE_ID added in the repo's secrets
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
BRANCHE_REF: ${{ github.event.pull_request.head.ref }}
run: |
npm init -y
npm install --unsafe-perm=true netlify-cli -g
netlify init
netlify deploy --alias=${BRANCHE_REF} --dir="_public" --message "Preview deploy from ${BRANCHE_REF}"
#--site="$NETLIFY_SITE_ID" --auth="$NETLIFY_AUTH_TOKEN"