Build website #191
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
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples | |
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '00 00 1 * *' | |
name: Build website | |
jobs: | |
pkgdown: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- {pkg: 'aion'} | |
- {pkg: 'alkahest'} | |
- {pkg: 'ananke'} | |
- {pkg: 'arkhe'} | |
- {pkg: 'dimensio'} | |
- {pkg: 'folio'} | |
- {pkg: 'isopleuros'} | |
- {pkg: 'kairos'} | |
- {pkg: 'khroma'} | |
- {pkg: 'kinesis'} | |
- {pkg: 'nexus'} | |
- {pkg: 'tabula'} | |
- {pkg: 'tekton'} | |
- {pkg: 'tesselle'} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
extra-repositories: https://tesselle.r-universe.dev | |
- name: Install system dependencies | |
run: sudo apt-get update -y && sudo apt-get install -y libglpk-dev | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
extra-packages: any::pkgdown, any::remotes, any::tekton | |
- name: Build site (latest release) | |
run: | | |
git clone https://github.com/tesselle/${{ matrix.config.pkg }} tmp && cd tmp | |
git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) | |
Rscript -e 'remotes::install_deps(pkgdir = ".", dependencies = TRUE)' | |
Rscript -e 'utils::install.packages(pkgs = ".", repos = NULL)' | |
Rscript -e 'pkgdown::build_site_github_pages(pkg = ".", dest_dir = "docs")' | |
- name: Upload pkgdown artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.config.pkg }} | |
path: tmp/docs | |
quarto: | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
needs: pkgdown | |
env: | |
GITHUB_PAT: ${{ secrets.TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
- name: Install quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
- name: Get data | |
run: | | |
Rscript -e 'source("metadata.R")' | |
- name: Render quarto project | |
uses: quarto-dev/quarto-actions/render@v2 | |
- name: Download pkgdown artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: _site | |
- name: Upload website artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: quarto | |
path: _site | |
deploy: | |
runs-on: ubuntu-latest | |
needs: quarto | |
env: | |
USER: ${{ secrets.DEPLOY_USER }} | |
SERVER: ${{ secrets.DEPLOY_HOST }} | |
REPO: ${{ secrets.DEPLOY_REPOSITORY }} | |
KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
steps: | |
- name: Download website artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: quarto | |
path: htdocs | |
- name: Add SSH key | |
run: | | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
echo "${KEY}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan ${SERVER} >> ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
- name: Push to production | |
run: | | |
git init -b main | |
git config --global user.email "[email protected]" | |
git config --global user.name "tesselle" | |
git remote add production ssh+git://${USER}@${SERVER}/${REPO} | |
git add * | |
git commit -m "Built site" | |
git push -f production main | |
- name: Deploy | |
run: ssh ${USER}@${SERVER} deploy ${REPO} main | |
- name: Clean | |
run: ssh ${USER}@${SERVER} clean ${REPO} main |