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

posts/2021/07/18/hugo-on-github-pages #41

Open
utterances-bot opened this issue Jun 30, 2022 · 3 comments
Open

posts/2021/07/18/hugo-on-github-pages #41

utterances-bot opened this issue Jun 30, 2022 · 3 comments

Comments

@utterances-bot
Copy link

Hugo on GitHub Pages | Olivia's blog

https://lunarwatcher.github.io/posts/2021/07/18/hugo-on-github-pages.html

Copy link

kitswas commented May 27, 2023

add [skip ci] to the commit message

Thanks a lot. Didn't know about this.
I hadn't even thought this could be possible.

You led me to find -
https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs

My use case is a bit different.
I have configured Doxygen to generate documentation for my projects.
The documentation is hosted on GH Pages.

Commits currently trigger a documentation build and a pages deployment simultaneously.
What would you recommend so that the Pages deployment is paused till the docs are built?

Copy link

kitswas commented May 27, 2023

P.S.: You also led me to find https://utteranc.es/
Another thank you for that.

@LunarWatcher
Copy link
Owner

I'd use the same setup I have for hugo; instead of pushing to main, push to a separate branch, and make that branch host GH Pages. Essentially, you'd have main and gh-pages (or whatever name you feel makes sense). By deploying from a separate branch, and only allowing automated commits on said branch, you ensure it isn't deployed before doxygen is done.

If you want the generated doxygen files to be on the main branch as well, you do what you currently do, but after you push to main, you also need something along the lines of

cd doxygen-output
git init
git remote add origin your-repo
git add -A
git commit -m "Update doxygen deployment"
git push --force origin gh-pages

Note that this will wipe the history of the gh-pages branch, which also happens to my deployment branch. You can avoid this with more scripting. I just wipe the history because it's convenient (particularly because I've struggled with Hugo not properly cleaning its output directory), and nothing is really lost. The history is preserved on the master branch instead

Obligatory warning: Be careful with --force. It can and will wipe stuff on the main branch (or any other branch) if the git push is malformed, or set to push somewhere unexpected. Use common sense, and keep a backup of the main branch for good measure


That said, I did just notice that there's a new option in GH Pages settings:

image

I have no idea how it works, but if it means you can define your own custom workflow for deployment, you can add, for instance,

if: "contains(github.event.head_commit.message, '[github pages deploy]')"

And change your Doxygen action to add [github pages deploy] to the commit message. The if statement would prevent the deployment action from being run unless the commit message contains that token (or some other token if you prefer something else), which would ensure the deployment only happens for the Doxygen commits. Note that this assumes the GitHub Actions option for GH Pages works the way I think it does. I haven't checked.

If it doesn't, using a separate branch is always an option.

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

No branches or pull requests

3 participants