-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
infra: automatically post documentation previews for PRs #4829
Conversation
23b0db7
to
b0d02c6
Compare
b0d02c6
to
6de1abd
Compare
@ilyagr, you know much more about the doc generation than I do. Will you have time to review this? |
I will take a look, yes. |
# | ||
# 1. ssh-keygen -t ed25519 -C "" -N "" -f <where to put the keypair> | ||
# 2. Add the public key to https://github.com/jj-preview/docs/settings/keys/new | ||
# 3. Add the private key to https://github.com/martinvonz/jj/settings/secrets/actions/new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing only @martinvonz can do this, right?
Speaking of which, I just invited Martin to the jj-preview org. It's a party now. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, Martin needs to add a GH secret. Or give someone a "CI/CD admin" role:
With the new CI/CD Admin role, organization owners and teams can now delegate comprehensive CI/CD management to individuals without the need to maintain a custom role
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a secret called DOCS_DEPLOY_KEY
. Its public key is:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH5kNau/89p02CNJy0I+ijuE0qZUp+HjhZgZLtJ64m9y
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I added the public key to https://github.com/jj-preview/docs/settings/keys. I also invited Martin to that org, but there's probably now no immediate need for him to join.
branch: 'main' | ||
clean: true | ||
target-folder: 'pr-${{ github.event.pull_request.number }}' | ||
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to add a comment: # Creating this is documented in docs-preview-deploy.yml
.
message: | | ||
**📖 Documentation preview is published to https://jj-preview.github.io/docs/pr-${{ env.PR_NUMBER }}.** | ||
Thanks for working on the docs! | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add:
This feature is experimental, feel free to open a bug or tell us in a chat if something is not working. We may remove it if it's too flaky.
You can always build and serve the docs on your own machine by following the instructions at https://martinvonz.github.io/jj/prerelease/contributing/#previewing-the-html-documentation
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@62fec3add6773ec5dbbf18d2ee4260911aa35cf4 | ||
with: | ||
folder: empty-dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Thinking out loud, we can fiddle with this later if necessary) This might create a lot of empty dirs.
I don't think it matters much, but perhaps a better approach would be:
- Deploy a file called
PR_CLOSED
to the dir in the docs repo here. No need to delete anything. - Have an action in the docs repo that deletes all dirs with PR_CLOSED marker if it's over 7 days old.
I'm not sure how well that will work if that action happens to happen while another action is deploying to the docs. But I'm also not sure it'd be worse than with this PR as is; I'm not sure how this PR will do if the cleanup action on one PR is running at the same time as the deploy action acts on another PR.
It is something we can discover experimentally, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might create a lot of empty dirs.
It actually deletes the dir entirely (I checked).
I'm not sure how well that will work if that action happens to happen while another action is deploying to the docs.
Good catch. In fact, GHA doesn't support a "workflow queue" at all — if you use concurrency:
, it will only keep one pending job in the queue.
I will fix that by disabling force
and single-commit
and switching to per-PR concurrency groups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: I will also delete the cleanup entirely b/c the extra complexity is not worth it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Thinking out loud) Would just adding the PR_CLOSED
file (or something like that) be too complex as well? Then we could occasionally clean up manually.
Unless we nuke the repo history, garbage collection won't save much git storage, but it might save on the amount of traffic needed to deploy the website. OTOH, GitHub seems to take care of that, so maybe it's not a problem (or we could assume that they are smart about it and use rsync
).
Ultimately, this is up to you.
I just spent several hours reading about GHA security and learned (among other things) that all workflows have access to repo secrets. We can mitigate that by creating a "deployment environment", scoping it to the
|
Thank you! I've moved the private key to the new |
GitHub closed this PR b/c I renamed the branch in my fork. I’ll make a new PR after fixing a few papercuts in the new version. |
This adds a new workflow that renders docs, publishes them to https://jj-preview.github.io/docs/, and posts a link to the PR thread.
Ignore all commits except for the last one. (uv changes are #4822)
How it looks in action: neongreen#1
TODOs
Checklist
If applicable:
CHANGELOG.md