Skip to content

Commit 23bb8b3

Browse files
committed
Add automated testing for publish action
Creates a test workflow that generates a documentation website from the repository READMEs and publishes it to gh-pages. This tests the full publish action workflow including the worktree credential handling. The workflow: - Runs on push to main and manual dispatch - Dynamically generates Quarto site from READMEs via heredoc - Fixes relative links to work in the rendered site - Publishes to gh-pages, testing the complete worktree code path Also creates a minimal documentation site at quarto-dev.github.io/quarto-actions/ as a useful side benefit.
1 parent 0ffb259 commit 23bb8b3

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

.github/docs/_quarto.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "Quarto Actions"
6+
navbar:
7+
left:
8+
- text: "Setup"
9+
href: setup.qmd
10+
- text: "Render"
11+
href: render.qmd
12+
- text: "Publish"
13+
href: publish.qmd
14+
right:
15+
- icon: github
16+
href: https://github.com/quarto-dev/quarto-actions
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Test Publish Action
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
test-publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
17+
- uses: ./setup
18+
with:
19+
version: release
20+
21+
# Generate website content from README files
22+
- name: Generate Quarto site
23+
run: |
24+
# Create working directory structure
25+
mkdir -p _site_source
26+
27+
# Copy Quarto config
28+
cp .github/docs/_quarto.yml _site_source/
29+
30+
# Define repo URL for link fixing
31+
REPO_URL="https://github.com/quarto-dev/quarto-actions"
32+
33+
# Function to fix links in a README
34+
fix_readme_links() {
35+
local file=$1
36+
# First: Fix known action page links to point to site pages
37+
sed -i \
38+
-e 's|\](./setup)|\](setup.qmd)|g' \
39+
-e 's|\](./render)|\](render.qmd)|g' \
40+
-e 's|\](./publish)|\](publish.qmd)|g' \
41+
"$file"
42+
# Second: All remaining ./ links point to GitHub
43+
sed -i "s|\](./|\](${REPO_URL}/tree/main/|g" "$file"
44+
}
45+
46+
# Copy and fix main README
47+
cp README.md _site_source/
48+
fix_readme_links _site_source/README.md
49+
50+
# Copy and fix action READMEs
51+
cp setup/README.md _site_source/setup-readme.md
52+
fix_readme_links _site_source/setup-readme.md
53+
54+
cp render/README.md _site_source/render-readme.md
55+
fix_readme_links _site_source/render-readme.md
56+
57+
cp publish/README.md _site_source/publish-readme.md
58+
fix_readme_links _site_source/publish-readme.md
59+
60+
# Generate index.qmd
61+
cat > _site_source/index.qmd <<'EOF'
62+
---
63+
title: "Quarto Actions"
64+
---
65+
66+
This site demonstrates the quarto-actions and tests the publish action.
67+
68+
{{< include README.md >}}
69+
EOF
70+
71+
# Generate action pages
72+
cat > _site_source/setup.qmd <<'EOF'
73+
---
74+
title: "Setup Action"
75+
---
76+
77+
{{< include setup-readme.md >}}
78+
EOF
79+
80+
cat > _site_source/render.qmd <<'EOF'
81+
---
82+
title: "Render Action"
83+
---
84+
85+
{{< include render-readme.md >}}
86+
EOF
87+
88+
cat > _site_source/publish.qmd <<'EOF'
89+
---
90+
title: "Publish Action"
91+
---
92+
93+
{{< include publish-readme.md >}}
94+
EOF
95+
96+
# Test the publish action
97+
- uses: ./publish
98+
with:
99+
target: gh-pages
100+
path: _site_source
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)