Skip to content

Commit bd14d1c

Browse files
authored
Merge branch 'main' into docs/cname-resources
2 parents 47f19fd + 54f82c6 commit bd14d1c

File tree

542 files changed

+35819
-3512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

542 files changed

+35819
-3512
lines changed

.github/workflows/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# About our workflows
2+
3+
This repository uses different workflows to automatically updates the published websites
4+
5+
- <https://quarto.org/> - The documentation for Quarto, published from the `main` branch
6+
- <https://prerelease.quarto.org/> - The documentation for Quarto prerelease, published from the `prerelease` branch
7+
8+
It also configures some website preview for pull requests, which are published to Netlify as deploy previews. The use non-production deploy and can be consulted to `deploy-preview-<PR number>.quarto.org`.
9+
10+
Note that technically, <prerelease.quarto.org> is also a deploy preview on Netlify (non-production website) but with a fixed URL.
11+
12+
## Workflow files: What they do
13+
14+
- `publish.yml` - The workflow that publishes the documentation from `main` and `prerelease` branches to netlify.
15+
- For stable release version, the doc is deployed from `main`, and published using `quarto publish netlify` command to production website on Netlify.
16+
- For prerelease version, the doc is deployed from `prerelease`, and published using Github Action `nwtgck/actions-netlify` which use Netlify API to deploy to a non-production website on Netlify.
17+
The prerelease website is build using a specific profile at render time, set in action using `QUARTO_PROFILE` environment variable.
18+
19+
- `preview.yml` - The workflow that creates a deploy preview for pull requests. It uses the same action `nwtgck/actions-netlify` to deploy to a non-production website on Netlify. The URL is `deploy-preview-<PR number>.quarto.org`.
20+
- PR previews are configured for any PR to `main` or`prerelease` branches.
21+
- They are automically created and updated when the PR is created and updated by a user with Contributor role.
22+
- For external PR, the preview can be triggered by adding a comment `/deploy-preview` on the PR.
23+
- Any rendering to prerelease also uses a specific profile at render time, set in action using `QUARTO_PROFILE` environment variable.
24+
25+
- `update-downloads.yml` - This workflow is triggered by a cron schedule. It retrieves information about latest release and prerelease on `quarto-dev/quarto-cli` repository and updates the download links on the website.
26+
- If there is a new version detected, it will commit the modified files and trigger a deploy of the website calling `publish.yml` workflow with `workflow_call` event trigger.
27+
- This applies to both `main` and `prerelease` branches
28+
- For `main` branch, we use `stefanzweifel/git-auto-commit-action` to detect changes and commit them to the `main` branch
29+
- For `prerelease` branch, we use `git cherry-pick` the commit from main following previous above step.
30+
- Then we trigger the `publish.yml` workflow with `workflow_call` event trigger for each of the branch.
31+
32+
- `upload-index.yml` - This workflow is triggered by a cron schedule. It updates the indexes for Algolia search engine, which powers the sites search.
33+
- `search.json` is built when the website is rendered and then it is deployed to the website.
34+
- This index file is retrieved on deployed website to be updated on Algolia.
35+
- Both `quarto.org` and `prerelease.quarto.org` indexes are updated in the same run - they each use one specific algolia index
36+
37+
- `port-to-prerelease.yml` - This workflow is used to sync changes made to main for quarto.org to prerelease branch for prerelease.quarto.org.
38+
- It is triggered when a PR is merged in to `main`. It can also be triggered manually by adding a comment `/sync-prerelease` on a merged PR.
39+
- This workflow uses [`korthout/backport-action`](https://github.com/korthout/backport-action) to create a PR with the changes merged into `main` branch to be synced to `prerelease` branch.
40+
- It will also write a new `/deploy-preview` comment in the new PR to trigger the preview deployment from `preview.yml`.
41+
- This is possible because it uses a fine-grained PAT token which allows a workflow to trigger another using usual event (GITHUB_TOKEN does not allow that usually). This is configured in repo secrets.
42+
43+
## Netlify Configurations
44+
45+
- This repo has a `_redirects` file in the root directory. Otherwise, configuration are made in NETLIFY UI. Quarto website is inside Posit Netlify account.
46+
- Automatic builds are turned off for this repo on Netlify because we currently need to render with Quarto CLI in Gihub Action CI before publishing the results.
47+
- API deploy is used currently, using npm netlify package through `nwtgck/actions-netlify` github actions. One think to know: Netlify has removed `deploy()` function from its npm package in version 7 and recommends now to use Netlify CLI instead. But we are still using the package for now in CI, but also for `quarto publish netlify`.
48+
- Deploy previews are possible with manual deploy using an alias configuration for the deploy command; This allows us to `deploy-preview-<PR number>` and `prerelease` alias to be used for the deploy previews.
49+
- This means our netlify website don't use automatic builds and automatic Branch deploy - Only deploy previews.
50+
- The website uses [Automatic Deploy Subdomains](https://docs.netlify.com/domains-https/custom-domains/automatic-deploy-subdomains/#use-a-new-custom-domain-for-your-automatic-deploy-subdomain) to have `prerelease.quarto.org` or `deploy-preview-<PR number>.quarto.org` working.
51+
52+
## Custom Domain
53+
54+
- `quarto.org` is registered in external registrar, but associated with Netlify DNS allowing use to use [custom domains](https://docs.netlify.com/domains-https/custom-domains/multiple-domains/).

.github/workflows/actions/release-info/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ inputs:
2727
required: true
2828

2929
runs:
30-
using: "node16"
30+
using: "node20"
3131
main: "index.js"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Port change to prerelease
2+
on:
3+
pull_request_target:
4+
types: [closed]
5+
issue_comment:
6+
types: [created]
7+
8+
permissions:
9+
contents: write # so it can comment
10+
pull-requests: write # so it can create pull requests
11+
checks: write # so it can create a check run
12+
13+
jobs:
14+
sync-to-prerelease:
15+
name: Backport pull request
16+
runs-on: ubuntu-latest
17+
# Don't run on closed unmerged pull requests and only PRs to main
18+
# or on comment made by Github Action Bot
19+
if: >
20+
(
21+
github.event.pull_request.merged &&
22+
github.event.pull_request.base.ref == 'main'
23+
) || (
24+
github.event_name == 'issue_comment' &&
25+
github.event.issue.pull_request &&
26+
github.event.comment.user.id != 41898282 &&
27+
startsWith(github.event.comment.body, '/sync-prerelease')
28+
)
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Create backport pull requests
33+
id: synced-pr
34+
# https://github.com/korthout/backport-action/releases/tag/v3.0.0
35+
uses: korthout/backport-action@7e7cb1977d64d20339e8fdec12c0a1a065371de7
36+
with:
37+
cherry_picking: auto
38+
branch_name: sync-${pull_number}-to-${target_branch}
39+
merge_commits: skip
40+
pull_title: '[Sync to ${target_branch}] ${pull_title}'
41+
pull_description: |
42+
# Description
43+
Sync of #${pull_number} to `${target_branch}`.
44+
45+
## Original PR
46+
47+
### ${pull_title}
48+
${pull_description}
49+
# Don't trigger on labels, and always PR to prerelease
50+
label_pattern: ''
51+
target_branches: prerelease
52+
53+
- name: Trigger deploy using a comment
54+
if: steps.synced-pr.outputs.was_successful == 'true'
55+
uses: actions/github-script@v7
56+
with:
57+
# special fine-grained token for issue comment trigger
58+
github-token: ${{ secrets.ISSUE_COMMENT_TRIGGER_PAT }}
59+
script: |
60+
await github.rest.issues.createComment({
61+
owner: context.repo.owner,
62+
repo: context.repo.repo,
63+
issue_number: "${{ steps.synced-pr.outputs.created_pull_numbers }}",
64+
body: "/deploy-preview",
65+
});

.github/workflows/preview.yml

Lines changed: 64 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
on:
22
pull_request:
3-
branches: [main, v1.4]
3+
branches: [main, prerelease]
44
issue_comment:
55
types: [created]
66

77
name: Deploy Preview
88

9+
concurrency:
10+
# Use github.event.pull_request.number on pull requests, so it's unique per pull request
11+
# Use github.event.issue.number on issue comments, so it's unique per comment
12+
# Use github.ref on other branches, so it's unique per branch
13+
group: ${{ github.workflow }}-${{ (github.event.pull_request && format('PR-{0}', github.event.pull_request.number)) || ( github.event.issue && format('comment-{0}', github.event.issue.number) ) || github.ref }}
14+
cancel-in-progress: true
15+
916
jobs:
1017
is-external-pr:
1118
# Be helpful with reviewer and remind them to trigger a deploy preview if the PR is from a fork.
@@ -17,13 +24,41 @@ jobs:
1724
echo "::error title=Manual action required for preview::PR from fork can't be deployed as preview to Netlify automatically. Use '/deploy-preview' command in comments to trigger the preview manually."
1825
shell: bash
1926

27+
role-of-commenter:
28+
if: github.event.issue.pull_request
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Check if commenter is a member, owner or collaborator
32+
id: commenter-check
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
commenter_role=$(gh api repos/$GITHUB_REPOSITORY/collaborators/${{ github.event.comment.user.login }}/permission --jq '.permission')
37+
echo "commenter_role=$commenter_role" >> "$GITHUB_OUTPUT"
38+
echo "author_association=${{ github.event.comment.author_association }}" >> "$GITHUB_OUTPUT"
39+
shell: bash
40+
2041
build-deploy-preview:
2142
# Deploy a preview only if
2243
# - the PR is not from a fork,
23-
# - requested by PR comment /deploy-preview
24-
if: |
25-
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork != true) ||
26-
(github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') && startsWith(github.event.comment.body, '/deploy-preview'))
44+
# - requested by PR comment /deploy-preview, from a repo user or github action bot (user id 41898282)
45+
# FIXME: We need to change the way we filter because somehow some MEMBER in API are seen as CONTRIBUTOR in CI
46+
if: >
47+
(
48+
github.event_name == 'pull_request' &&
49+
github.event.pull_request.head.repo.fork != true
50+
) ||
51+
(
52+
github.event.issue.pull_request &&
53+
(
54+
github.event.comment.user.id == '41898282' ||
55+
github.event.comment.user.login == 'gordonwoodhull' ||
56+
github.event.comment.author_association == 'MEMBER' ||
57+
github.event.comment.author_association == 'OWNER' ||
58+
github.event.comment.author_association == 'COLLABORATOR'
59+
) &&
60+
startsWith(github.event.comment.body, '/deploy-preview')
61+
)
2762
2863
runs-on: ubuntu-latest
2964
steps:
@@ -44,12 +79,35 @@ jobs:
4479
with:
4580
version: ${{ steps.github-release.outputs.version }}
4681

82+
- name: Is it for prerelease website ?
83+
id: prerelease-docs-check
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
run: |
87+
if [ "${{ github.event.pull_request.base.ref }}" == "prerelease" ]; then
88+
echo "is_prerelease_docs=true" >> "$GITHUB_OUTPUT"
89+
elif [ -n "${{ github.event.issue.pull_request.url }}" ]; then
90+
# This will trigger when not pull request event, so a PR comment event.
91+
# we need to get the base info from PR number the comment is made in
92+
base_ref=$(gh -R $GITHUB_REPOSITORY pr view ${{ github.event.issue.number }} --json baseRefName --jq '.baseRefName')
93+
if [ "$base_ref" == "prerelease" ]; then
94+
echo "is_prerelease_docs=true" >> "$GITHUB_OUTPUT"
95+
else
96+
echo "is_prerelease_docs=false" >> "$GITHUB_OUTPUT"
97+
fi
98+
else
99+
echo "is_prerelease_docs=false" >> "$GITHUB_OUTPUT"
100+
fi
101+
shell: bash
102+
47103
- name: Render
48104
uses: quarto-dev/quarto-actions/render@v2
105+
env:
106+
QUARTO_PROFILE: ${{ steps.prerelease-docs-check.outputs.is_prerelease_docs == 'true' && 'prerelease-docs' || '' }}
49107

50108
- name: Deploy Preview to Netlify as preview
51109
id: netlify-deploy
52-
uses: nwtgck/actions-netlify@v2
110+
uses: nwtgck/actions-netlify@v3
53111
env:
54112
NETLIFY_SITE_ID: 2a3da659-672b-4e5b-8785-e10ebf79a962
55113
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

.github/workflows/publish.yml

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
on:
22
workflow_dispatch:
33
push:
4-
branches: main
4+
branches:
5+
- main
6+
- prerelease
57
workflow_call:
68
inputs:
79
ref:
810
required: true
911
description: 'The ref to trigger the workflow on'
1012
type: string
13+
prerelease:
14+
required: true
15+
description: 'Whether to deploy prerelease or release site'
16+
type: boolean
17+
default: false
1118

1219
name: Quarto Publish
1320

21+
concurrency:
22+
group: ${{ format('{0} - {1} - {2}', github.workflow, github.ref, inputs.prerelease && 'prerelease' || 'main') }}
23+
cancel-in-progress: true
24+
1425
jobs:
1526
build-deploy:
1627
runs-on: ubuntu-latest
1728
steps:
1829
- name: Check out repository
1930
uses: actions/checkout@v4
2031
with:
21-
# if called fomr workflow_call event, checkout the ref otherwise use default
32+
# if called from workflow_call event, checkout the ref otherwise use default
2233
ref: ${{ inputs.ref || '' }}
2334

2435
- name: Get latest pre-release from github
@@ -33,8 +44,48 @@ jobs:
3344
with:
3445
version: ${{ steps.github-release.outputs.version }}
3546

36-
- name: Render and Publish
47+
- name: Render
48+
uses: quarto-dev/quarto-actions/render@v2
49+
env:
50+
QUARTO_PROFILE: ${{ (inputs.prerelease || (contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.ref == 'refs/heads/prerelease')) && 'prerelease-docs' || '' }}
51+
52+
- name: Publish release website
53+
# Only do this step if
54+
# - workflow is called for release deploy, with inputs.prerelease being false. It should not trigger if inputs.prerelease is null.
55+
# and in GHA null == false is true. That is why we convert to string and compare.
56+
# - workflow is triggered by push event on main branch
57+
# - workflow is triggered by workflow_dispatch event
58+
# (we need to protect also from workflow_dispatch inherited from workflow_call event - where inputs.prerelease is defined)
59+
if: ${{ format('{0}', inputs.prerelease) == 'false' || (!inputs.prerelease && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.ref == 'refs/heads/main') }}
3760
uses: quarto-dev/quarto-actions/publish@v2
3861
with:
3962
target: netlify
4063
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
64+
render: false
65+
66+
- name: Deploy Prerelease website to Netlify
67+
# Only do this step if
68+
# - workflow is called for release deploy with inputs.prerelease being true. It should not trigger if inputs.prerelease is null.
69+
# Though as in GHA null means false, no need to cast to string
70+
# - workflow is triggered by push event on main branch
71+
# - workflow is triggered by workflow_dispatch event
72+
# (we need to protect also from workflow_dispatch inherited from workflow_call event - where inputs.prerelease is defined)
73+
if: ${{ inputs.prerelease || (format('{0}', inputs.prerelease) != 'false' && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.ref == 'refs/heads/prerelease') }}
74+
id: netlify-deploy
75+
uses: nwtgck/actions-netlify@v3
76+
env:
77+
NETLIFY_SITE_ID: 2a3da659-672b-4e5b-8785-e10ebf79a962
78+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
79+
with:
80+
publish-dir: './_site'
81+
production-deploy: false
82+
github-token: ${{ secrets.GITHUB_TOKEN }}
83+
deploy-message: |
84+
Deploy from GHA: ${{ format('manual from {0} at commit {1}', github.ref_name, github.sha) }}
85+
alias: prerelease
86+
# these all default to 'true'
87+
enable-pull-request-comment: false
88+
enable-commit-comment: false
89+
enable-commit-status: true
90+
overwrites-pull-request-comment: false
91+
timeout-minutes: 1

.github/workflows/update-downloads.yml

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ jobs:
1010
outputs:
1111
changes_detected: ${{ steps.auto-commit.outputs.changes_detected }}
1212
commit: ${{ steps.auto-commit.outputs.commit_hash }}
13+
commit_prerelease: ${{ steps.cherry-pick-prerelease.outputs.commit_hash }}
1314
steps:
1415
- name: Checkout Repo
1516
uses: actions/checkout@v4
1617
# with:
1718
# token: ${{ secrets.COMMIT_PAT }}
19+
1820
- name: Regenerate Download Json
1921
uses: ./.github/workflows/actions/release-info
2022
with:
@@ -24,8 +26,9 @@ jobs:
2426
redirects-path: '_redirects'
2527
redirects-template: /download/latest/$$prefix$$-$$suffix$$.$$extension$$
2628
pre-redirects-template: /download/prerelease/$$prefix$$-$$suffix$$.$$extension$$
27-
github-token: ${{ github.token }}
28-
- name: Commit Changes
29+
github-token: ${{ github.token }}
30+
31+
- name: Commit Changes to main branch
2932
id: auto-commit
3033
uses: stefanzweifel/git-auto-commit-action@v5
3134
with:
@@ -34,14 +37,39 @@ jobs:
3437
commit_user_email: [email protected]
3538
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
3639
skip_checkout: true
40+
41+
- name: Cherry-pick change to prerelease branch
42+
id: cherry-pick-prerelease
43+
if: ${{ steps.auto-commit.outputs.changes_detected == 'true' }}
44+
run: |
45+
git config --global user.name 'github-actions[bot]'
46+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
47+
git checkout prerelease
48+
git cherry-pick ${{ steps.auto-commit.outputs.commit_hash }}
49+
git push origin prerelease
50+
# set an output for github action with the resulted commit of cherry-pick command
51+
echo "commit_hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
3752
3853
# If a new commit has been made with updated downloads,
3954
# then publish the changes using the new commit as ref to checkout
4055
# in the reusable publish workflow
41-
publish-changes:
56+
publish-changes-release:
4257
needs: [ update-downloads ]
4358
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
4459
uses: ./.github/workflows/publish.yml
4560
with:
4661
ref: ${{ needs.update-downloads.outputs.commit }}
62+
prerelease: false
63+
secrets: inherit
64+
65+
# If a new commit has been made with updated downloads,
66+
# then publish the changes using the new commit as ref to checkout
67+
# in the reusable publish workflow
68+
publish-changes-prerelease:
69+
needs: [ update-downloads ]
70+
if: ${{ needs.update-downloads.outputs.changes_detected == 'true' }}
71+
uses: ./.github/workflows/publish.yml
72+
with:
73+
ref: ${{ needs.update-downloads.outputs.commit_prerelease }}
74+
prerelease: true
4775
secrets: inherit

0 commit comments

Comments
 (0)