Gestion des dépendances avec renv #1856
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |