build_and_deploy #666
This file contains hidden or 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: build_and_deploy | |
| on: | |
| schedule: | |
| - cron: '0 03 * * *' | |
| push: | |
| branches: | |
| - main | |
| env: | |
| RENV_PATHS_ROOT: ~/.cache/R/renv | |
| RENV_CONFIG_REPOS_OVERRIDE: https://cloud.r-project.org | |
| jobs: | |
| blogdown: | |
| name: build_and_push_to_gh_pages | |
| runs-on: ubuntu-24.04 | |
| env: | |
| GOOGLESHEETS4_PASSWORD: ${{ secrets.GOOGLESHEETS4_PASSWORD }} | |
| steps: | |
| # - uses: r-lib/actions/setup-r@v2 | |
| # with: | |
| # r-version: '4.4.1' | |
| # - uses: r-lib/actions/setup-r-dependencies@v2 | |
| # with: | |
| # extra-packages: | | |
| # any::rcmdcheck | |
| # any::XML | |
| # | |
| # - name: Install ubuntu deps | |
| # run: | | |
| # sudo apt-get update | |
| # sudo apt-get install -y --no-install-recommends \ | |
| # curl \ | |
| # libcurl4-openssl-dev \ | |
| # libsodium-dev | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Setup R and system dependencies | |
| uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: '4.4.1' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| curl \ | |
| libcurl4-openssl-dev \ | |
| libsodium-dev \ | |
| libglpk40 | |
| - name: Restore R packages (renv) | |
| shell: Rscript {0} | |
| run: | | |
| install.packages("renv", repos = "https://cloud.r-project.org") | |
| # ensure CRAN is stable for all installs | |
| options(repos = c(CRAN = "https://cloud.r-project.org")) | |
| renv::restore(prompt = FALSE) | |
| # - name: Install R package dependencies (with sysreqs) | |
| # uses: r-lib/actions/setup-r-dependencies@v2 | |
| # with: | |
| # cache-version: 1 | |
| # extra-packages: | | |
| # any::rcmdcheck | |
| # any::XML | |
| # needs: sysreqs | |
| # - name: Cache packages | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: ${{ env.RENV_PATHS_ROOT }} | |
| # key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-renv- | |
| # - name: Restore packages | |
| # shell: Rscript {0} | |
| # run: | | |
| # if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") | |
| # renv::restore() | |
| - name: Set up Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| - name: Run pipeline | |
| shell: Rscript {0} | |
| run: | | |
| targets::tar_make() | |
| - name: Render doc | |
| shell: bash | |
| run: quarto render index.qmd | |
| - name: Checkout gh-pages branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| path: gh-pages | |
| - name: Copy output and rename README.html to index.html | |
| run: | | |
| cp -R output/* gh-pages/ | |
| mv index.html gh-pages/index.html | |
| mv output/* gh-pages/output/ || true | |
| - name: Commit and push changes | |
| run: | | |
| cd gh-pages | |
| git config --local user.name "GitHub Actions" | |
| git config --local user.email "actions@github.com" | |
| git add . | |
| git commit -m "Deploy website" || echo "No changes to commit" | |
| git push | |