Reordering checkout #28
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
name: Website | |
on: | |
push: | |
branches: [main, prod] | |
pull_request: | |
branches: [main, prod] | |
release: | |
types: [published] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
container: rocker/tidyverse:4.4.1 | |
name: rendering-${{ matrix.files.fn }} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
strategy: | |
fail-fast: false | |
matrix: | |
files: | |
- {fn: "epiestim_vignette"} | |
- {fn: "EpiLPS_vignette"} | |
- {fn: "EpiNow2_vignette"} | |
- {fn: "RtEstim_vignette"} | |
- {fn: "eval_vignette"} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check cache | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
key: ${{ format('vignette-{0}-{1}', matrix.files.fn, hashFiles(format('./vignettes/{0}.Rmd', matrix.files.fn))) }} | |
path: | |
${{ format('vignettes/{0}.html', matrix.files.fn) }} | |
- name: Install packages | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
install2.r -n4 EpiLPS EpiNow2 lemon ggtext kableExtra here | |
installGithub.r EpiForeSITE/summrt | |
installGithub.r mrc-ide/EpiEstim | |
installGithub.r dajmcdon/rtestim | |
- name: Render the file ${{ matrix.files.fn }} | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: Rscript --vanilla -e 'rmarkdown::render("vignettes/${{ matrix.files.fn }}.Rmd", output_format = "rmarkdown::html_document")' | |
- name: Save cache | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: actions/cache/save@v3 | |
with: | |
key: ${{ format('vignette-{0}-{1}', matrix.files.fn, hashFiles(format('./vignettes/{0}.Rmd', matrix.files.fn))) }} | |
path: | |
${{ format('vignettes/{0}.html', matrix.files.fn) }} | |
- name: Restore cache | |
uses: actions/cache/restore@v3 | |
if: steps.cache.outputs.cache-hit == 'true' | |
with: | |
key: ${{ format('vignette-{0}-{1}', matrix.files.fn, hashFiles(format('./vignettes/{0}.Rmd', matrix.files.fn))) }} | |
path: | |
${{ format('vignettes/{0}.html', matrix.files.fn) }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.files.fn }} | |
path: vignettes/${{ matrix.files.fn }}* | |
collect: | |
runs-on: ubuntu-latest | |
container: rocker/tidyverse:4.4.0 | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: . | |
- name: Moving files | |
run: | | |
mkdir _website | |
mv *_vignette/* _website/ | |
- name: Render index page | |
run: | | |
quarto render README.md --to html -o index.html | |
mv index.html _website/ | |
- name: Upload artifacts | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
name: github-pages | |
path: _website/ | |
deploy: | |
# Deploy to the github-pages environment | |
# but not on PRs | |
if: ${{ github.event_name != 'pull_request' }} | |
permissions: | |
contents: write | |
id-token: write | |
pages: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: collect | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
artifact_name: github-pages | |
preview: true | |