Skip to content

Commit 494ab42

Browse files
committed
Merge branch 'main' into worktree-screenshot-tool
# Conflicts: # docs/websites/images/navbar-tools-dark.png # docs/websites/images/navbar-tools.png # docs/websites/website-navigation.qmd
2 parents 1430697 + afe4421 commit 494ab42

233 files changed

Lines changed: 12224 additions & 962 deletions

File tree

Some content is hidden

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

.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: "node20"
30+
using: "node24"
3131
main: "index.js"
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Optimize Images
2+
3+
on:
4+
push:
5+
branches: [main, prerelease]
6+
paths:
7+
- '**/*.png'
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
env:
17+
OXIPNG_VERSION: "10.1.0"
18+
19+
jobs:
20+
optimize-png:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Check out repository
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Install oxipng
29+
env:
30+
GH_TOKEN: ${{ github.token }}
31+
run: |
32+
mkdir -p "$RUNNER_TEMP/oxipng"
33+
gh release download "v${OXIPNG_VERSION}" \
34+
--repo oxipng/oxipng \
35+
--pattern "*x86_64-unknown-linux-musl.tar.gz" \
36+
--output - | tar xz --strip-components=1 -C "$RUNNER_TEMP/oxipng"
37+
38+
- name: Get changed PNG files
39+
id: changed-pngs
40+
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
41+
with:
42+
files: '**/*.png'
43+
separator: '\n'
44+
45+
- name: Optimize PNGs
46+
if: steps.changed-pngs.outputs.any_changed == 'true'
47+
env:
48+
ALL_CHANGED_FILES: ${{ steps.changed-pngs.outputs.all_changed_files }}
49+
run: |
50+
echo "$ALL_CHANGED_FILES" | while IFS= read -r file; do
51+
if [ -f "$file" ]; then
52+
echo "Optimizing: $file"
53+
"$RUNNER_TEMP/oxipng/oxipng" -o 4 -i 0 --strip safe "$file"
54+
fi
55+
done
56+
57+
- name: Commit optimized images
58+
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
59+
with:
60+
commit_message: "Optimize PNG images with oxipng"
61+
commit_user_name: github-actions[bot]
62+
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
63+
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
64+
file_pattern: '**/*.png'

.github/workflows/port-to-prerelease.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ jobs:
2727
startsWith(github.event.comment.body, '/sync-prerelease')
2828
)
2929
steps:
30-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v6
3131

3232
- name: Create backport pull requests
3333
id: synced-pr
34-
# https://github.com/korthout/backport-action/releases/tag/v3.0.0
35-
uses: korthout/backport-action@7e7cb1977d64d20339e8fdec12c0a1a065371de7
34+
# https://github.com/korthout/backport-action/releases/tag/v4.2.0
35+
uses: korthout/backport-action@4aaf0e03a94ff0a619c9a511b61aeb42adea5b02
3636
with:
3737
cherry_picking: auto
3838
branch_name: sync-${pull_number}-to-${target_branch}
@@ -52,7 +52,7 @@ jobs:
5252

5353
- name: Trigger deploy using a comment
5454
if: steps.synced-pr.outputs.was_successful == 'true'
55-
uses: actions/github-script@v7
55+
uses: actions/github-script@v8
5656
with:
5757
# special fine-grained token for issue comment trigger
5858
github-token: ${{ secrets.ISSUE_COMMENT_TRIGGER_PAT }}

.github/workflows/preview.yml

Lines changed: 77 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
on:
22
pull_request:
33
branches: [main, prerelease]
4+
paths-ignore:
5+
- '.github/**'
46
issue_comment:
57
types: [created]
68

@@ -63,10 +65,24 @@ jobs:
6365
runs-on: ubuntu-latest
6466
steps:
6567
- name: Check out repository
66-
uses: actions/checkout@v4
67-
with:
68+
uses: actions/checkout@v6
69+
with:
6870
ref: refs/pull/${{ github.event.pull_request.number || github.event.issue.number }}/merge
6971

72+
# On issue_comment events (e.g. /deploy-preview), github.event.pull_request
73+
# is not populated so tj-actions/changed-files can't determine the base commit
74+
# to diff against. Fetch it from the API so we can pass it explicitly.
75+
- name: Get PR base SHA
76+
if: github.event_name != 'pull_request'
77+
id: pr-info
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |
81+
pr_number=${{ github.event.issue.number }}
82+
base_sha=$(gh -R $GITHUB_REPOSITORY pr view $pr_number --json baseRefOid --jq '.baseRefOid')
83+
echo "base_sha=$base_sha" >> "$GITHUB_OUTPUT"
84+
shell: bash
85+
7086
- name: Get latest pre-release from github
7187
id: github-release
7288
env:
@@ -127,20 +143,23 @@ jobs:
127143

128144
- name: Get changed files
129145
id: changed-files
130-
uses: tj-actions/changed-files@v46.0.5
146+
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
131147
with:
148+
base_sha: ${{ github.event.pull_request.base.sha || steps.pr-info.outputs.base_sha }}
132149
files: |
133150
# don't consider modifications on file used for includes for now.
134151
license.md
135152
docs/**/[^_]*.qmd
136153
docs/**/[^_]*.md
137154
docs/extensions/listings/*.yml
155+
docs/reference/**/*.json
156+
docs/cli/*.json
138157
json: true
139158
escape_json: false
140159

141160
- name: Create custom PR comment
142161
if: github.event.pull_request || github.event.issue.pull_request
143-
uses: actions/github-script@v7
162+
uses: actions/github-script@v8
144163
env:
145164
DEPLOY_URL: ${{ steps.netlify-deploy.outputs.deploy-url }}
146165
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -149,40 +168,76 @@ jobs:
149168
script: |
150169
const prNumber = context.payload.pull_request?.number || context.payload.issue.number;
151170
const deployUrl = process.env.DEPLOY_URL;
152-
const changedFiles = JSON.parse(process.env.CHANGED_FILES);
153-
171+
const changedFiles = JSON.parse(process.env.CHANGED_FILES || '[]');
172+
154173
let commentBody = `## 📝 Preview Deployment\n\n`;
155174
commentBody += `🔍 Full site preview: [${deployUrl}](${deployUrl})\n\n`;
156-
175+
157176
if (changedFiles.length > 0) {
158-
commentBody += `### 🔄 Modified Documents\n\n`;
177+
// Explicit mapping for files that don't follow standard naming conventions
178+
const specialFileMapping = {
179+
'docs/extensions/listings/shortcodes-and-filters.yml': 'docs/extensions/index.html',
180+
'docs/extensions/listings/journal-articles.yml': 'docs/extensions/index.html',
181+
'docs/extensions/listings/custom-formats.yml': 'docs/extensions/index.html',
182+
'docs/extensions/listings/revealjs-formats.yml': 'docs/extensions/index.html',
183+
'docs/extensions/listings/revealjs.yml': 'docs/extensions/index.html',
184+
'docs/cli/cli-info.json': 'docs/reference/index.html',
185+
};
186+
187+
// Projects/ JSON files have many-to-one mapping to .qmd pages
188+
const projectsJsonMapping = {
189+
'book': 'docs/reference/projects/books.html',
190+
'manuscript': 'docs/reference/projects/manuscripts.html',
191+
'project': 'docs/reference/projects/options.html',
192+
'preview': 'docs/reference/projects/options.html',
193+
'serve': 'docs/reference/projects/options.html',
194+
};
195+
const projectsDefault = 'docs/reference/projects/websites.html';
196+
197+
// Resolve each changed file to its preview URL path
198+
// Group files by their target page for deduplication
199+
const pageToFiles = new Map();
200+
159201
changedFiles.forEach(file => {
160202
let fileUrlPath;
161203
162-
// Define a mapping for special files to their corresponding URLs
163-
const specialFileMapping = {
164-
'docs/extensions/listings/shortcodes-and-filters.yml': 'docs/extensions/index.html',
165-
'docs/extensions/listings/journal-articles.yml': 'docs/extensions/index.html',
166-
'docs/extensions/listings/custom-formats.yml': 'docs/extensions/index.html',
167-
'docs/extensions/listings/revealjs-formats.yml': 'docs/extensions/index.html',
168-
'docs/extensions/listings/revealjs.yml': 'docs/extensions/index.html'
169-
};
170-
171-
// Check if the file is in the special mapping
172204
if (specialFileMapping[file]) {
173205
fileUrlPath = specialFileMapping[file];
174206
} else if (file.endsWith('.qmd') || file.endsWith('.md')) {
175-
// Convert path to URL (removing file extension and adding appropriate path)
176207
fileUrlPath = file.replace(/\.(qmd|md)$/, '.html');
208+
} else if (file.startsWith('docs/reference/projects/') && file.endsWith('.json')) {
209+
const stem = file.split('/').pop().replace('.json', '');
210+
fileUrlPath = projectsJsonMapping[stem] || projectsDefault;
211+
} else if (file.endsWith('.json')) {
212+
// Generic: formats/, cells/, metadata/ JSON have sibling .qmd files
213+
fileUrlPath = file.replace(/\.json$/, '.html');
177214
}
178215
179216
if (fileUrlPath) {
180-
const fileUrl = `${deployUrl}/${fileUrlPath}`;
181-
commentBody += `- [${file}](${fileUrl})\n`;
217+
if (!pageToFiles.has(fileUrlPath)) {
218+
pageToFiles.set(fileUrlPath, []);
219+
}
220+
pageToFiles.get(fileUrlPath).push(file);
182221
}
183222
});
223+
224+
if (pageToFiles.size > 0) {
225+
commentBody += `### 🔄 Modified Documents\n\n`;
226+
for (const [page, files] of pageToFiles) {
227+
const fileUrl = `${deployUrl}/${page}`;
228+
if (files.length === 1) {
229+
commentBody += `- [${page}](${fileUrl})\n`;
230+
} else {
231+
// Multiple source files map to one page - show page with file summary
232+
const basenames = files.map(f => f.split('/').pop());
233+
const shown = basenames.slice(0, 3).join(', ');
234+
const rest = basenames.length > 3 ? `, +${basenames.length - 3} more` : '';
235+
commentBody += `- [${page}](${fileUrl}) (${shown}${rest})\n`;
236+
}
237+
}
238+
}
184239
}
185-
240+
186241
github.rest.issues.createComment({
187242
issue_number: prNumber,
188243
owner: context.repo.owner,

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Check out repository
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v6
3131
with:
3232
# if called from workflow_call event, checkout the ref otherwise use default
3333
ref: ${{ inputs.ref || '' }}

.github/workflows/test-algolia-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout Repo
10-
uses: actions/checkout@v4
10+
uses: actions/checkout@v6
1111
- name: Setup Ruby
1212
uses: ruby/setup-ruby@v1
1313
with:

.github/workflows/update-downloads.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
prerelease_version: ${{ steps.get-versions.outputs.prerelease_version }}
1515
steps:
1616
- name: Checkout Repo
17-
uses: actions/checkout@v4
17+
uses: actions/checkout@v6
1818
# with:
1919
# token: ${{ secrets.COMMIT_PAT }}
2020

@@ -38,13 +38,12 @@ jobs:
3838
3939
- name: Commit Changes to main branch
4040
id: auto-commit
41-
uses: stefanzweifel/git-auto-commit-action@v5
41+
uses: stefanzweifel/git-auto-commit-action@v7
4242
with:
4343
repository: .
4444
commit_user_name: Github Action Runner
4545
commit_user_email: runner@quarto.org
4646
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
47-
skip_checkout: true
4847

4948
- name: Cherry-pick change to prerelease branch
5049
id: cherry-pick-prerelease

0 commit comments

Comments
 (0)