-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathupdate-prerelease-reference.yml
More file actions
150 lines (128 loc) · 4.85 KB
/
update-prerelease-reference.yml
File metadata and controls
150 lines (128 loc) · 4.85 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Update Prerelease Reference Pages
on:
workflow_dispatch:
push:
branches:
- prototype/ci-reference-pages # TEMP: remove after testing
schedule:
# Run daily at 6am UTC
- cron: "0 6 * * *"
jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout prerelease branch
uses: actions/checkout@v4
with:
ref: prerelease
- name: Get current documented version
id: current
run: |
version=$(jq -r '.version' docs/cli/cli-info.json)
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Current documented version: $version"
- name: Get latest prerelease version
id: latest
env:
GH_TOKEN: ${{ github.token }}
run: |
# Find the latest prerelease from quarto-cli
latest=$(gh api repos/quarto-dev/quarto-cli/releases \
--jq '[.[] | select(.prerelease)] | .[0].tag_name' \
| sed 's/^v//')
echo "version=$latest" >> "$GITHUB_OUTPUT"
echo "Latest prerelease version: $latest"
- name: Check for existing PR
id: check-pr
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check if there's already an open PR for this version
pr_count=$(gh pr list \
--base prerelease \
--state open \
--search "Update reference pages for v${{ steps.latest.outputs.version }}" \
--json number \
--jq 'length')
echo "existing_pr=$pr_count" >> "$GITHUB_OUTPUT"
echo "Existing PRs for this version: $pr_count"
- name: Determine if update needed
id: should-update
run: |
if [ "${{ steps.current.outputs.version }}" != "${{ steps.latest.outputs.version }}" ] && \
[ "${{ steps.check-pr.outputs.existing_pr }}" = "0" ]; then
echo "update=true" >> "$GITHUB_OUTPUT"
echo "Update needed: new version available and no existing PR"
else
echo "update=false" >> "$GITHUB_OUTPUT"
echo "No update needed"
fi
# --- Setup steps (only run if update needed) ---
- name: Install Quarto (prerelease)
if: steps.should-update.outputs.update == 'true'
uses: quarto-dev/quarto-actions/setup@v2
with:
version: "pre-release"
- name: Verify Quarto version
if: steps.should-update.outputs.update == 'true'
run: quarto --version
- name: Clone quarto-cli at matching tag
if: steps.should-update.outputs.update == 'true'
run: |
git clone --depth 1 --branch v${{ steps.latest.outputs.version }} \
https://github.com/quarto-dev/quarto-cli.git \
../quarto-cli
- name: Setup R
if: steps.should-update.outputs.update == 'true'
uses: r-lib/actions/setup-r@v2
- name: Install R dependencies
if: steps.should-update.outputs.update == 'true'
uses: r-lib/actions/setup-r-dependencies@v2
with:
packages: |
jsonlite
knitr
here
tidyverse
fansi
xfun
# --- Run reference generation scripts ---
- name: Generate format/cell/project reference JSON
if: steps.should-update.outputs.update == 'true'
run: |
quarto run tools/reference.ts
- name: Generate CLI reference
if: steps.should-update.outputs.update == 'true'
run: |
# Generate CLI info JSON
quarto dev-call cli-info > docs/cli/cli-info.json
# Generate markdown from JSON
quarto run tools/reference-cli-generate-md.R
# --- Create PR ---
- name: Create branch and PR
if: steps.should-update.outputs.update == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
version="${{ steps.latest.outputs.version }}"
branch="auto/prerelease-reference-v${version}"
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git checkout -b "$branch"
git add -A
git commit -m "Update reference pages for v${version}"
git push origin "$branch"
gh pr create \
--base prerelease \
--head "$branch" \
--title "Update reference pages for v${version}" \
--body "$(cat <<EOF
Automated update of reference documentation for Quarto prerelease v${version}.
## Changes
- Format/cell/project reference JSON files (from \`tools/reference.ts\`)
- CLI reference markdown files (from \`tools/reference-cli-generate-md.R\`)
## Review checklist
- [ ] Spot check a few reference pages render correctly
- [ ] No unexpected deletions
EOF
)"