Migrating from GitHub Actions to SourceHut Builds by Bruno Bernardino
Search
Faster, more ethical, no AI, and EU-based.
After a couple of years running Gitea and Forgejo, I moved my private repos back to GitHub, because my instance was DDoS'd a couple of times and I found myself spending more time than I had wanted upgrading and maintaining it.
I didn't like it, and soon after they started pushing hard for Copilot and AI everywhere, I started looking for alternatives again. Codeberg became the obvious choice for mirroring public repos (I'm still in the process of doing this), but their terms don't allow private, non-FOSS projects, so I eventually chose SourceHut for those, and I've been a very happy customer for a few months, now!
I'd like to share how I migrated a couple of Github Actions for a Deno app with a docker compose based deploy via SSH from GitHub to SourceHut Builds, where I've got a ton more control (they're also faster and run closer to my infrastructure in EU)!
Hopefully this will help someone else with a similar problem.
Here's a sample .github/workflows/deploy.yml file I used to have:
name: Deploy<br>on:<br>push:<br>branches:<br>- main<br>workflow_dispatch:<br>jobs:<br>deploy:<br>runs-on: ubuntu-latest<br>steps:<br>- uses: actions/checkout@v6<br>- name: Configure SSH<br>run: |<br>mkdir -p ~/.ssh/<br>echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/server.key<br>chmod 600 ~/.ssh/server.key<br>cat >>~/.ssh/config<br>env:<br>SSH_KEY: ${{ secrets.SERVER_SSH_KEY }}<br>- name: Deploy via SSH<br>run: ssh server 'cd apps/example && git pull origin main && git remote prune origin && docker system prune -f && docker compose up -d --build && docker compose ps && docker compose logs'
And here's the new .builds/deploy.yml file:
submitter:<br>git.sr.ht:<br>enabled: true<br>allow-refs:<br>- refs/heads/main<br>secrets:<br>- ><br>image: alpine/latest<br>tasks:<br>- configure_ssh: |<br>cat >>~/.ssh/config<br>StrictHostKeyChecking no<br>END<br>cat ~/.ssh/config<br>- deploy_via_ssh: |<br>ssh server 'cd apps/example && git pull origin main && git remote prune origin && docker system prune -f && docker compose up -d --build && docker compose ps && docker compose logs'
And the .github/workflows/test.yml file (make test calls deno test and a few other deno lint/format/check commands):
name: Run Tests<br>on: [push]<br>jobs:<br>test:<br>runs-on: ubuntu-latest<br>steps:<br>- uses: actions/checkout@v6<br>- uses: denoland/setup-deno@v2<br>with:<br>deno-version-file: .dvmrc<br>- run: |<br>make test
And the respective new .builds/test.yml file:
submitter:<br>git.sr.ht:<br>enabled: true<br>allow-refs:<br>- refs/heads/main<br>secrets:<br>- ><br>image: ubuntu/lts<br>tasks:<br>- test: |<br>sudo apt-get update && sudo apt-get install -y curl unzip make<br>curl -fsSL https://deno.land/install.sh | sh -s v$(cat repo-name/.dvmrc)<br>export PATH="$HOME/.deno/bin:$PATH"<br>cd repo-name<br>make test
As you can see, they're mostly similar, but the subtle differences still took me some iterations to get the right Deno setup (which I do via .dvmrc), for example. The SSH Key is necessary on the second file in order to be able to check out the private repo. If it's public, you won't need that.
It's also possible there are improvements I can make to these, which I'm missing, so if you know of any, please let me know.
Thank you for your attention and kindness. I really appreciate it!
These are written with no AI assistance whatsoever, which means there might be potential typos, so please let me know if you find any.