davideisinger.com

My personal website
Log | Files | Refs | README

index.md (4243B)


      1 ---
      2 title: "Migrating from GitHub to SourceHut"
      3 date: 2024-11-05T12:21:55-05:00
      4 draft: false
      5 tags:
      6 - meta
      7 references:
      8 - title: "Switching to SourceHut Builds - Tim Hårek"
      9   url: https://timharek.no/blog/switching-to-sourcehut-builds
     10   date: 2024-11-01T03:59:37Z
     11   file: timharek-no-becx2e.txt
     12 - title: "Cryptocurrency is an abject disaster"
     13   url: https://drewdevault.com/2021/04/26/Cryptocurrency-is-a-disaster.html
     14   date: 2024-10-31T20:10:12Z
     15   file: drewdevault-com-yuxzdw.txt
     16 ---
     17 
     18 I've moved this site's repository from [GitHub][1] to [SourceHut][2], an alternative, open-source Git host. I thought I'd take a few minutes to explain the why and the how.
     19 
     20 [1]: https://github.com/
     21 [2]: https://sourcehut.org/
     22 
     23 <!--more-->
     24 
     25 I've been on GitHub since 2008, and I still use it every day as part of my job. I've no major complaints -- I'm still worlds happier using it than when I'm forced to use Jira or similar. Still, something has shifted in the last 16 years.
     26 
     27 I get regular emails from their salespeople trying to upsell us on more expensive enterprise plans; that's how it goes in a capitalist society, but I prefer my tech a little scrappier. I'm not crazy about Git -- open-source, decentralized technology -- becoming largely synonymous with a closed-source, centralized platform owned by a three-trillion dollar company, nor about my work and personal coding activity being all mixed up together. Furthermore, the way they've used open-source code to train up their LLM (Copilot) that they then sell back to developers doesn't sit right with me.
     28 
     29 I learned about SourceHut from [Tim Hårek][3] and have been following along for a few years. A thread on Mastodon (alas, lost in the void) about Copilot finally motivated me to sign up. I happily paid $20 to support the effort as well as to get access to SourceHut Builds, their GitHub Actions equivalent ([this post about why they require a paid account to use CI][4] is a gem).
     30 
     31 [3]: https://timharek.no/blog/switching-to-sourcehut-builds
     32 [4]: https://drewdevault.com/2021/04/26/Cryptocurrency-is-a-disaster.html
     33 
     34 After a few evenings of tinkering, I've got this site (as well as my [Markdown link renumbering tool][5]) moved over. I'm pretty anti-[bikeshedding][6] at work, but this is my place to be exactly as fussy as my heart desires.
     35 
     36 [5]: https://git.sr.ht/~dce/mdrenum
     37 [6]: https://en.wikipedia.org/wiki/Law_of_triviality
     38 
     39 ### Setting up SourceHut Builds
     40 
     41 Adding a new remote is as simple as
     42 
     43 ```sh
     44 git remote rename origin github
     45 git remote add origin [email protected]:~dce/davideisinger.com
     46 git push origin main
     47 ```
     48 
     49 But switching from GitHub Actions to SourceHut Builds took some doing. A few things to note:
     50 
     51 * There's no analog to GitHub's [Actions Marketplace][7]. You've got what's available via the OS package manager, and beyond that, you'll need to install things by hand. [Here's how I install Bun][8], for example.
     52 
     53 [7]: https://github.com/marketplace?type=actions
     54 [8]: https://git.sr.ht/~dce/mdrenum/tree/main/item/.build.yml#L14
     55 
     56 * `&` doesn't work for starting background tasks. Building this site requires starting a local [image server][9] and then calling it from Hugo. On GitHub, I could start the server with `bundle exec ruby dither.rb &`, but SourceHut seems to strip off the `&`, starting the process in the foreground and thus hanging the build. Switching over to `rackup` with the `--daemonize` option works fine.
     57 
     58 [9]: /journal/encrypt-and-dither-photos-in-hugo/#2-build-a-tiny-image-server
     59 
     60 * Secrets go in files, not environment variables. If you need a secret as an environment variable, do [something like this][10]. Be sure to disable logging before you do this -- it's verbose in surprising ways (see ["Keeping your secrets a secret"][11] in the docs).
     61 
     62 [10]: https://git.sr.ht/~dce/davideisinger.com/tree/main/.build.yml#L38
     63 [11]: https://man.sr.ht/builds.sr.ht/#keeping-your-secrets-a-secret
     64 
     65 * Add stuff to `~/.buildenv` (which runs before every step) to reduce duplication. See [docs][12] and examples for [this site][13] and [mdrenum][14].
     66 
     67 [12]: https://man.sr.ht/builds.sr.ht/#build-environment
     68 [13]: https://git.sr.ht/~dce/davideisinger.com/tree/main/.build.yml#L21
     69 [14]: https://git.sr.ht/~dce/mdrenum/tree/main/item/.build.yml#L15-17