Build and deploy to GitHub Pages #65
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 to GitHub Pages | |
# We don't want another build triggered from our deployment branch (master in this instance) | |
on: | |
push: | |
branches-ignore: | |
- master | |
schedule: | |
# Runs on the 1st of every month at 4PM | |
- cron: "0 16 1 * *" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
GIT_AUTHOR_NAME: "Jason Yao" | |
GIT_AUTHOR_EMAIL: "[email protected]" | |
DEPLOY_ACCESS_TOKEN: ${{ secrets.DEPLOY_ACCESS_TOKEN }} | |
BRANCH_REF_NAME: ${{ github.head_ref }} | |
SHA_COMMIT_HASH: ${{ github.sha }} | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
# Deploy pipeline metadata | |
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | |
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
- name: Extracts the current branch name | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | |
id: extract_branch | |
- run: echo "🔎 The name of your branch is ${{ steps.extract_branch.outputs.branch }} and your repository is ${{ github.repository }}." | |
# Sets up environment | |
- name: Checkout repo code | |
uses: actions/checkout@v4 | |
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | |
- name: Python 3 setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.4' # Version range or exact version of a Python version to use, using SemVer's version range syntax | |
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified | |
cache: 'pip' # caching pip dependencies | |
# We install dev since we're running tests- if we're on our | |
# local and don't need to run tests, we can just do: | |
# pip install -r requirements-core.txt | |
# | |
# NOTE: In the 2024 Aug move to actions/setup-python@v5, there was a requirement to move dependencies | |
# to a requirements.txt file, so we move the core logic to requirements-core.txt, and do a nested recursive | |
# call from inside of requirements.txt | |
- run: pip install -r requirements.txt | |
- name: Cache Texlive | |
id: cache-texlive | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-texlive-dependencies | |
with: | |
path: | | |
/tmp/texlive | |
$HOME/.texlive | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('/tmp/texlive/package-manifest.txt') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
# fonts-font-awesome is for the resume pdf generation | |
# ghostscript is for the .pdf -> .png conversion | |
# Attempting to directly install texlive-xetex doesn't work and clashes with the TexLive package manager, since it installs | |
# an older version which clashes in the PATH | |
# Shellcheck is a dependency in our testing step, and used to be included by default in previous *nix CI/CD environments, but as | |
# of the bump to v4 of these GitHub Action steps, now needs to be installed separately | |
- name: Install dependencies | |
run: sudo apt update && sudo apt -y install fonts-font-awesome ghostscript shellcheck | |
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | |
# Generates data output files | |
- name: Installs texlive and python dependencies | |
# We source here since texlive manager state is required | |
run: source bin/install_dependencies | |
- name: Test | |
run: bin/test | |
- name: Build | |
run: bin/build | |
- name: Deploy | |
run: bin/deploy ${{ steps.extract_branch.outputs.branch }} |