Skip to content

Deploy Production

Deploy Production #729

name: "Deploy Production"
on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
workflow_dispatch: {}
permissions: {}
jobs:
deploy-production:
name: Build & Deploy
runs-on: ubuntu-latest
timeout-minutes: 15
environment:
name: Production
url: ${{ steps.vercel-action.outputs.preview-url }}
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.10"
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: "22"
- name: Build Assets
run: npm ci && npm run prod
# Ruby must be set up after running "npm ci" because installing hugo-bin via npm
# removes the vendor directory that is created by "bundle install"
# https://github.com/fenneclab/hugo-bin/blob/a5500e4f622f46886947d3438243bd97cfe6c04c/lib/install.js#L28-L30
- name: Setup Ruby
uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
with:
ruby-version: "3.2"
bundler-cache: true
- name: Fetch Documentation
run: |
python -m pip install poetry
poetry install --no-root --only main
poetry run python bin/website build
- name: Build
run: npx hugo --minify --logLevel info
- name: Build search index
continue-on-error: true
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
ALGOLIA_INDEX_NAME: ${{ secrets.ALGOLIA_INDEX_NAME }}
ALGOLIA_INDEX_FILE: "algolia.json"
run: |
bundle exec bin/build_index.rb
npm run algolia
- name: Deploy
uses: amondnet/vercel-action@de09aeac2ace6599ec9b11ef87558759a496bac4 # v42.3.0
id: vercel-action
with:
vercel-version: 50.44.0
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: python-poetry
github-comment: false
vercel-args: "--prod"
working-directory: public