Introduction
This is part 2 of a 3 part series on how this blog is built and managed automatically. This post is standalone for anyone who wants to install and render a Quarto project on Github using workflows.
So far in our adventure, I’ve explained how you set up Azure Static Web Apps and the wider set-up of Quarto for websites.
Benefits of Quarto on Github?
By using Github to render your Quarto documents, you can achieve full CI/CD, which allows you to collaborate and push your documents to their various destinations. You don’t need to have Quarto installed locally to make changes; everything is guaranteed to be repeatable.
You will no longer need to store any rendered documents in your repository either. This is especially great when you build a website as it renders a _site folder.
Installing Quarto via the command line
The official Posit site (whom created) Quarto website discusses how you can download quarto and install it on Linux using a .deb file. We will use this to install Posit onto our Machine within Github Workflows.
First we will need to set up our job. This involves the checking out of the code (so we can use it to render our site).
Then we will install the gdebi dependency as reference on the Posit documentation.
Now we will download the latest quarto linux .deb file using CURL.
After this we can install the .deb file on the github machine. Using -y argument means we will agree to any prompts sent to us from installation
jobs:
render_site:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install GDebi first
run: sudo apt-get install gdebi-core
- name: Download the deb file
run: sudo curl -LO https://quarto.org/download/latest/quarto-linux-amd64.deb
- name: Install the deb file
run: sudo apt-get install -y ./quarto-linux-amd64.deb
- Now we have successfully downloaded and install Quarto, we can run a check to validate everything is installed correctly.
- name: Verify Install
run: /usr/local/bin/quarto check
- Everything has gone well! Now we can render our documents. We can either render all documents or provide a specific name. Should you wish to render with advanced configuration please read here
- name: render site
run: quarto render
- We can now upload our file as an artfact from our github workflow for later consumption in other workflows (e.g upload to web or local file storage etc) or should you wish you can download a full zip manually. Below shows you how to upload a _site directory for a rendered website, you can adjust as you require.
- name: Upload _site directory for deploy job
uses: actions/upload-artifact@v1
with:
name: site_deployment
path: _site
The full YAML is provided at the bottom.
Optional
Do you need to install R into your github action? Well you can with this code below
Install_R:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install R
run: sudo apt-get install -y r-base
Learn how to deploy to azure static web apps in part 3