Skip to content
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

Add GitHub Actions workflow for generating static docs #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pcolby
Copy link
Contributor

@pcolby pcolby commented Oct 21, 2023

Relates to #17.

This PR adds a new workflow for automatically generating the project docs, so they can (optionally) be hosted via GitHub Pages.

Prerequisite

Before merging this PR (assuming it's approved), someone should add an orphan doc branch to the repo. It would look something like this:

git clone git@github.com:cutelyst/cutelee.git cutelee-doc
cd cutelee-doc
git checkout --orphan doc
rm -rf .clang-format .github .travis.yml *
touch .nojekyll
git add .nojekyll
git commit -m 'Create orphan branch for static docs'
git push

More than happy to explain that more, but you're probably already aware of how that works 🤷🏻‍♂️ You can see an example of how that branch will look here: https://github.com/pcolby/cutelee/tree/doc (the docs directly will be created by the workflow if its not there yet).

How it Works

The workflow it split into two jobs. The first job ("generate") will:

  1. run on all pushes and pull requests
  2. build the project's docs target
  3. upload the docs to the workflow run's artifacts - this is handy, because people can download and review them from work-in-progress branches and PRs if they want to.

Then, the second job ("publish"):

  1. only runs on pushes to master, and only if the first job passed.
  2. checks out the doc branch
  3. removes all of the doc (html) content from the checkout
  4. downloads the artifact from the first job, replacing the previous docs
  5. checks for any changes, and if there are any, commits those changes and pushes an update to the doc branch.

This way, the doc branch always maintains a copy of the latest docs from master.

GitHub Pages

Optionally, you can then enable GitHub Pages on this repo. Go to https://github.com/cutelyst/cutelee/settings/pages and set the source to the doc branch and the /docs folder, like this:

image

Then the Cutelee docs should be available at https://cutelyst.github.io/cutelee/

In the meantime, you can see how they look on my clone: https://pcolby.github.io/cutelee/

I'm more than happy to help / explain anything further. And of course, if you want me to adjust anything, such as using a different branch name, etc, just let me know 😊

Cheers!

@pcolby
Copy link
Contributor Author

pcolby commented Oct 21, 2023

I have no idea what that failed "pre-commit.ci" check is... the details link goes to an non-existent domain 🤷🏻‍♂️ But do let me know if it indicates something wrong with this PR that I should fix 🙂 Thanks.

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.

1 participant