You would need to do that in your CI workflow
- Have a workflow that renders the document in the Github Action Workspace
- Commit this new rendered HTML document into the gh pages branch
I think it would be something like that. I don't have a live example at end - We should definitely make one
Steps would be (following one the example action actions/examples at master · r-lib/actions · GitHub
- install R
- install Pandoc
- install packages dependencies (or track them using renv and restore the project
- use
rmarkdown::render()
to render the Rmd doc inside GHA workflow
- Commit the result from GHA to the gh-page branch and not the main one.
For the last step you could find some existing actions usuful like Deploy to GitHub Pages · Actions · GitHub Marketplace · GitHub that works well to deploy to GH page a directory you would have created during the previous step of the workflow. There is also GitHub - peaceiris/actions-gh-pages: GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly. but I only use the former one.
You could also use only git command on your workflow to change branch but this is more advanced I believe.
Hope it helps.
(And I note the need of more example and helper function for publication - thanks for the feedback!)