Build website #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
# 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: | |
quarto: | |
runs-on: ubuntu-latest | |
if: ${{ always() }} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_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")' | |
Rscript -e 'source("issues.R")' | |
Rscript -e 'source("downloads.R")' | |
- name: Render quarto project | |
uses: quarto-dev/quarto-actions/render@v2 | |
- 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 |