Skip to content

Update workshop09-pres-fr.Rmd #51

Update workshop09-pres-fr.Rmd

Update workshop09-pres-fr.Rmd #51

on:
push:
branches:
- main
paths:
- pres-fr/**
- .github/workflows/deploy_pres-fr.yml
repository_dispatch:
types: [pong_presentation]
name: render-presentation-fr
jobs:
repository-dispatch-received:
name: Dispatch received - starting all jobs here
runs-on: ubuntu-latest
steps:
- name: Event Information
run: |
echo "Event '${{ github.event.action }}' received from '${{ github.event.client_payload.repository }}'"
- name: Acknowledge - dispatch response to received pong
if: github.event.action == 'pong_presentation'
run: |
curl -X POST https://api.github.com/repos/QCBSRworkshops/templateWorkshops/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.ACCESS_TOKEN }} \
--data '{"event_type": "acknowledged_presentation_en", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
presentation-fr-job:
name: Render the presentation for this workshop
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
working-directory: pres-fr
steps:
- name: πŸ›ŽοΈ Checkout repository
uses: actions/checkout@v3
- name: πŸ’» Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: 4.2.2
- name: πŸ’Ύ Cache R packages
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: r-${{ hashFiles('DESCRIPTION') }}
- name: πŸ’» Install pandoc and pandoc citeproc
uses: r-lib/actions/setup-pandoc@v2
- name: πŸ’» Install R packages and dependencies if needed
run: |
Rscript -e 'list.of.packages <- c("rmarkdown", "xaringan", "remotes");
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])];
if(length(new.packages) > 0) {
install.packages(new.packages, dependencies = TRUE)
print(paste0("The following package was installed:", new.packages))} else
if(length(new.packages) == 0) {
print("All packages have been previously installed and fetched from cache.")}'
- name: 🧢 Render presentation
run: Rscript -e 'rmarkdown::render("workshop09-pres-fr.Rmd")'
- name: πŸ“œ Create script using purl
run: |
Rscript -e 'knitr::purl("workshop09-pres-fr.Rmd",documentation = 0,output = "workshop09-script-fr.R");
script <- readLines("workshop09-script-fr.R");
script <- gsub("## ", "", script);
script <- script[-(1:34)];
write(script, file = "workshop09-script-fr.R");
file.copy("workshop09-script-fr.R", "_pres/")'
- name: πŸ”Ί Upload artifact containing the presentation
uses: actions/upload-artifact@v3
with:
name: pres-fr
path: pres-fr/
# Need to first create an empty gh-pages branch
# see https://pkgdown.r-lib.org/reference/deploy_site_github.html
# and also add secrets for an ACCESS_TOKEN
checkout-and-deploy:
name: Checkout and deploy the presentation within the gh-pages repository
runs-on: ubuntu-latest
needs: presentation-fr-job
steps:
- name: πŸ›ŽοΈ Checkout again
uses: actions/checkout@v3
with:
persist-credentials: false
- name: πŸ”» Download artifact containing the presentation
uses: actions/download-artifact@v3
with:
# Artifact name
name: pres-fr # optional
# Destination path
path: pres-fr/ # optional
- name: πŸ’Ž Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
branch: gh-pages # The branch the action should deploy to.
folder: pres-fr/
target-folder: pres-fr # The folder the action should deploy
clean: true