Skip to content

Revamp documentation building, deployment and cleanup#292

Merged
ValerianRey merged 20 commits intomainfrom
doc-version-build-deploy
Apr 4, 2025
Merged

Revamp documentation building, deployment and cleanup#292
ValerianRey merged 20 commits intomainfrom
doc-version-build-deploy

Conversation

@PierreQuinton
Copy link
Copy Markdown
Contributor

@PierreQuinton PierreQuinton commented Apr 1, 2025

  • Add build-deploy-docs.yml to build the documentation and deploy it to the right folder(s) of TorchJD/documentation repo whenever a pull request is opened, synchronized or reopened, whenever a push is made to the main branch, and whenever a version tag is pushed.
  • Add cleanup-pr-docs to delete the documentation contained in a folder of TorchJD/documentation whenever the corresponding PR is closed, and to push the changes to the main branch of TorchJD/documentation.

TODO after merging:

  • Delete TorchJD/test
  • Add the new action to the list of mandatory status checks in the settings of TorchJD/torchjd
  • Delete the gh-pages branch in TorchJD/torchjd
  • (when we're ready) Delete build_deploy_documentation.yml
  • (when we're ready) Disable gh-pages in TorchJD/torchjd
  • (when we're ready) Change DNS setting so that torchjd.org redirects to torchjd.github.io/documentation

@PierreQuinton PierreQuinton added the cc: ci Conventional commit type for changes to the CI (Github workflows and actions). label Apr 1, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…gs and main. Also clean up docs related to PRs when the PR is closed.
@PierreQuinton PierreQuinton force-pushed the doc-version-build-deploy branch from a5535aa to f247c78 Compare April 1, 2025 20:10
@ValerianRey
Copy link
Copy Markdown
Contributor

ValerianRey commented Apr 3, 2025

I think I would rather have another repo for the built documentation (unless this is not doable). Otherwise, the size of TorchJD/torchjd will grow uncontrollably, which will slow down clones and hence possibly other actions.

The alternative would be to use --single-branch and to specify a branch when cloning, but this would require to change the way other actions make their clone (which we might not be able to always control), the way users will clone (which, again, we have no control over), and it will only fetch the main branch, while we would have liked to fetch everything but the gh-pages branch.

This seems related: peaceiris/actions-gh-pages#35

ValerianRey and others added 8 commits April 4, 2025 00:17
When I suggested Python 3.13.1 instead of 3.12.3 in `CONTRIBUTING.md` (4ed413e), I should have also changed the python version of build_deploy_documentation.yml to 3.13, but I forgot. The reason is that I think it's better to use the latest Python version whenever we can, whether it be for users, contributors or even github actions. Since this PR will also end up with the removal of build_deploy_documentation.yml, I think it's a good time to also update Python to 3.13 in the new build-deploy-docs.yml file.
- This is to match the name of the secret that I just created in the settings of TorchJD/torchjd
@ValerianRey
Copy link
Copy Markdown
Contributor

I followed the steps indicated in https://github.com/peaceiris/actions-gh-pages?tab=readme-ov-file#%EF%B8%8F-deploy-to-external-repository-external_repository. Basically, we now specify the target repository (TorchJD/documentation), and we need to prove our right to push to this repository.

I then followed ChatGPT's advice to setup the required ssh keys. To do that, I created an ssh key pair on my computer. I then added the public key as a Deploy key of TorchJD/documentation, with write access to it. This means that anyone knowing the matching private key is allowed to push to TorchJD/documentation. To make this "anyone" be TorchJD/torchjd, I added the private key to the secrets owned by TorchJD/torchjd. I named it DOCUMENTATION_DEPLOY_KEY (note that in the README of peaceiris/actions-gh-pages they name it ACTIONS_DEPLOY_KEY, but I think the name DOCUMENTATION_DEPLOY_KEY is more precise for us).

IT WORKS!!!

I think I will delete the private key from my computer and store it in my personal bitwarden (not in this order), but we should try to have a shared bitwarden at some point @PierreQuinton

@ValerianRey
Copy link
Copy Markdown
Contributor

As far as I understand, it would also be fine to just delete the private key from my computer, so that only torchjd has them. If we ever need them, we can always generate new ones.

@ValerianRey
Copy link
Copy Markdown
Contributor

The documentation of TorchJD/documentation can be visited at https://torchjd.github.io/documentation/

@ValerianRey
Copy link
Copy Markdown
Contributor

ValerianRey commented Apr 4, 2025

It would be really nice to be able to simply click on the "Build and Deploy Documentation / build (pull_request)" action (from the drop down list of actions that ran on the PR) and to be redirected directly to the right folder of the built and deployed documentation.

EDIT: I managed to have a suboptimal solution for this. I added a last step named "Add documentation link to summary". When it's run, it will create a summary for the action, containing the link. So to visit the built documentation, we will have to click on the check status of the documentation build / deployment, then click on "Summary", then click on the link "📄 View Deployed Documentation". Without creating a Github App, I don't think it's possible to do really better than this. We could alternatively add a comment to the PR, but I don't really like this as it will create a lot of noise. So I think the solution of the Summary link is good enough for now.

@PierreQuinton
Copy link
Copy Markdown
Contributor Author

Very cool, I think this is ready to merge right? We could then test it with other Prs, test the cleanup, with push to mains and finally newtag. Then the documentqtion could go to torchjd.org

@ValerianRey
Copy link
Copy Markdown
Contributor

I just fixed the cleanup-pr-docs.yml action to also write to the TorchJD/documentation repo, and to use the same ssh key (DOCUMENTATION_DEPLOY_KEY) to be allowed to write to it. I also removed gh-pages from the path, since I think we don't use that anymore (the pr/ folder is right at the root of the repo now).

Since it's hard to test this, I added a workflow_dispatch trigger to be able to manually run this action. We can remove it when we know that it works.

@ValerianRey ValerianRey closed this Apr 4, 2025
@ValerianRey ValerianRey reopened this Apr 4, 2025
@ValerianRey
Copy link
Copy Markdown
Contributor

Closing and reopening the PR successfully launched the clean up action, which succeeded to push its commit to TorchJD/documentation main.

@ValerianRey ValerianRey changed the title Update Build and deploy docs CI Revamp documentation building and deployment Apr 4, 2025
@ValerianRey ValerianRey changed the title Revamp documentation building and deployment Revamp documentation building, deployment and cleanup Apr 4, 2025
@ValerianRey ValerianRey merged commit d7f9f36 into main Apr 4, 2025
15 checks passed
@ValerianRey ValerianRey deleted the doc-version-build-deploy branch April 4, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: ci Conventional commit type for changes to the CI (Github workflows and actions).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants