build_and_deploy #116
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: build_and_deploy | |
on: | |
schedule: | |
- cron: '0 03 * * *' | |
push: | |
branches: | |
- main | |
env: | |
RENV_PATHS_ROOT: ~/.cache/R/renv | |
jobs: | |
blogdown: | |
name: build_and_push_to_gh_pages | |
runs-on: ubuntu-20.04 | |
env: | |
GOOGLESHEETS4_PASSWORD: ${{ secrets.GOOGLESHEETS4_PASSWORD }} | |
steps: | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: '4.4.1' | |
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: Cache packages | |
uses: actions/cache@v1 | |
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 | |
run: quarto render index.qmd | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v3 | |
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/ | |
- name: Commit and push changes | |
run: | | |
cd gh-pages | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "[email protected]" | |
git add . | |
git commit -m "Deploy website" | |
git push | |