Deploying to Source Hut
Deploying to Source Hut⌗
I had to figure some thigns out while trying to get my particular setup of Hugo deployed to SourceHut, because I made some interesting choices:
- the source repo is private
- using a custom domain (this one)
- using a theme as a git submodule
If those very specific constraints apply to you too, use the following tweaks to the Quick Start Guide:
- Set up the domain CNAME to point to
pages.st.ht.
; in my case this was a CNAME forwww
. This was needed for the deploy to complete successfully.www IN CNAME pages.sr.ht.
- The Build manifest reference got me to the page that describes setting up a private key.
- If you have already added a key to your profile, you should use
ssh-keygen -C <new-key-name>
along with any other options.new-key-name
is what the key will get named in the secrets management page. This private key is necessary to access your repo from the build instances. The summary of that is adding the following two top-level keys to.build.yml
:secrets: - <ssh key secret uuid from secrets dashboard> sources: - git@git.sr.ht:~yourname/your-private-repo
- Add
hugo
to the value part of thepackages
key in.build.yml
packages: - hut - hugo
- Update the
package
key to have this as the value (note that-b
passed tohugo
changes the URLs to be relative to your domain and-C public
totar
only compresses files in that folder):package: | cd $site git submodule update hugo -b https://$site tar -C public -cvz . > ../site.tar.gz
- If you’ve done all that, your
.build.yaml
should be looking something like:image: alpine/edge oauth: pages.sr.ht/PAGES:RW packages: - hut - hugo environment: site: <your-website-url> repo: <your-website-repo> secrets: - <uuid-of-your-sh-key-from-step-3> sources: - git@git.sr.ht:~<username>/$repo tasks: - package: | cd $repo git submodule update hugo -b https://$site tar -C public -cvz . > ../site.tar.gz - upload: | hut pages publish -d $site site.tar.gz
I figured this out mostly in a couple of hours, after not having spent any time doing ops-y stuff for ages, so yay!