use workflows gh token #3
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 * * 1' # weekly 3am Monday | |
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: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
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 | |
- 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 | |
# mv index.html gh-pages/index.html | |
- name: Copy output | |
run: | | |
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 |