-
Notifications
You must be signed in to change notification settings - Fork 842
91 lines (83 loc) · 3.92 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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