Skip to content

Conversation

hydrolarus
Copy link
Collaborator

This also adds a robots.txt so that PR previews don't get indexed by search engines.

Also deduplicates the theme in the repository using symlinks. They will still be duplicated once deployed, but that should be okay.

Copy link
Contributor

Thank you for your PR! A preview of your changes is live at
https://docs.clash-lang.org/pr/14/

@DigitalBrains1
Copy link
Member

DigitalBrains1 commented Oct 20, 2025

This currently runs:

mdbook build
mkdir -p public/pr
cp CNAME public/
cp robots.txt public/
mkdir -p public
git fetch --depth=1 origin +gh-pages:refs/remotes/origin/gh-pages
git archive --prefix=public/ refs/remotes/origin/gh-pages -- ':(glob)pr-*/**' | tar x || true

So:

  • mdbook build will create the directory public
  • mkdir -p public/pr will create the directories public and public/pr
  • mkdir -p public will create the directory public
  • tar x will create the directories public, public/pr and many more, unless there is no open PR; it doesn't create any dirs then.

I think the cps can just fail and abort CI if mdbook build did not create the public directory. Something is very wrong then, and it should abort. Note that the cps are very explicitly "copy to this directory"; if the directory doesn't exist, cp does an error exit.

If you don't like that, please just do

mdbook build
mkdir -p public
cp CNAME public/
cp robots.txt public/
git fetch --depth=1 origin +gh-pages:refs/remotes/origin/gh-pages
git archive --prefix=public/ refs/remotes/origin/gh-pages -- ':(glob)pr-*/**' | tar x || true

because it's a bit much :-D.

Note that there's another issue with that code, see message below.

Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to adjust the glob for git archive

@DigitalBrains1
Copy link
Member

Thanks for going forward with this!

@hydrolarus
Copy link
Collaborator Author

Thanks for the review! I kept the mkdir -p public/pr just because it makes me feel better when the PR build action uses ./pr as a destination dir to publish.

@hydrolarus
Copy link
Collaborator Author

cleaned up the directory creation even more! Should be good now?

@DigitalBrains1
Copy link
Member

Do you mind if I squash the latest commit into the "add root book" commit? I like clean histories :-D

@hydrolarus
Copy link
Collaborator Author

No no, go ahead if you want to do it :)

@DigitalBrains1 DigitalBrains1 merged commit 83930ea into main Oct 21, 2025
1 check passed
github-actions bot added a commit that referenced this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants