Skip to content

Merge pull request #1475 from quarto-dev/sync-1472-to-prerelease #2879

Merge pull request #1475 from quarto-dev/sync-1472-to-prerelease

Merge pull request #1475 from quarto-dev/sync-1472-to-prerelease #2879

Workflow file for this run

on:
workflow_dispatch:
push:
branches:
- main
- prerelease
workflow_call:
inputs:
ref:
required: true
description: 'The ref to trigger the workflow on'
type: string
prerelease:
required: true
description: 'Whether to deploy prerelease or release site'
type: boolean
default: false
name: Quarto Publish
concurrency:
group: ${{ format('{0} - {1} - {2}', github.workflow, github.ref, inputs.prerelease && 'prerelease' || 'main') }}
cancel-in-progress: true
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
# if called from workflow_call event, checkout the ref otherwise use default
ref: ${{ inputs.ref || '' }}
- name: Get latest pre-release from github
id: github-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo version=$(gh api repos/quarto-dev/quarto-cli/releases | jq -r 'map(select(.prerelease)) | first | .tag_name | sub("^v";"")') >> "$GITHUB_OUTPUT"
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: ${{ steps.github-release.outputs.version }}
- name: Render
uses: quarto-dev/quarto-actions/render@v2
env:
QUARTO_PROFILE: ${{ (inputs.prerelease || (contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.ref == 'refs/heads/prerelease')) && 'prerelease-docs' || '' }}
- name: Publish release website
# Only do this step if
# - workflow is called for release deploy, with inputs.prerelease being false. It should not trigger if inputs.prerelease is null.
# and in GHA null == false is true. That is why we convert to string and compare.
# - workflow is triggered by push event on main branch
# - workflow is triggered by workflow_dispatch event
# (we need to protect also from workflow_dispatch inherited from workflow_call event - where inputs.prerelease is defined)
if: ${{ format('{0}', inputs.prerelease) == 'false' || (!inputs.prerelease && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.ref == 'refs/heads/main') }}
uses: quarto-dev/quarto-actions/publish@v2
with:
target: netlify
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
render: false
- name: Deploy Prerelease website to Netlify
# Only do this step if
# - workflow is called for release deploy with inputs.prerelease being true. It should not trigger if inputs.prerelease is null.
# Though as in GHA null means false, no need to cast to string
# - workflow is triggered by push event on main branch
# - workflow is triggered by workflow_dispatch event
# (we need to protect also from workflow_dispatch inherited from workflow_call event - where inputs.prerelease is defined)
if: ${{ inputs.prerelease || (format('{0}', inputs.prerelease) != 'false' && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.ref == 'refs/heads/prerelease') }}
id: netlify-deploy
uses: nwtgck/actions-netlify@v3
env:
NETLIFY_SITE_ID: 2a3da659-672b-4e5b-8785-e10ebf79a962
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
with:
publish-dir: './_site'
production-deploy: false
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: |
Deploy from GHA: ${{ format('manual from {0} at commit {1}', github.ref_name, github.sha) }}
alias: prerelease
# these all default to 'true'
enable-pull-request-comment: false
enable-commit-comment: false
enable-commit-status: true
overwrites-pull-request-comment: false
timeout-minutes: 1