Update GitHub Actions workflow #173
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 * *' | |
push: | |
branches: [main] | |
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: 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: | |
path: _site | |
- name: Deploy | |
run: | | |
## Create the SSH directory and give it the right permissions | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
## Add the SSH key | |
echo "$KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
## Use ssh-keyscan to scan the keys of the server | |
ssh-keyscan -H $HOST >> ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
## Push | |
git remote -v | grep -w production || git remote add production ssh+git://$USER@$HOST/$REPO | |
git push -f production master | |
ssh $USER@$HOST deploy $REPO | |
ssh $USER@$HOST clean $REPO |