I’ve been trying to figure this part out for a few days. I have my own Forgejo instance and a website each running in separate containers on a Raspberry Pi. I also have the forgejo runner installed in another docker container. I followed some guides to set up forgejo actions, but all the guides end with a simple example that basically just runs the “ls” command.

I tried running ‘docker compose up’ inside my workflow, but it fails with “docker: command not found”. So how do you use the workflow to actually update the website in the other container?

I think I’d prefer keeping everything in docker but I’d be okay with making the workflow run some script on the host machine if needed.

  • Possibly linux@lemmy.zip
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    19 hours ago

    First make make a script that deploys it. Then convert that script into a workflow. In the end your workflow will be 3 steps:

    1. Checkout the repo
    2. Create SSH key
    3. Copy to host and restart service

    For the SSH key I would encode it via base64 before storing it as a forgejo secret. You can do via something like this:

    cat private.key | base64 -w 0

    And then in your workflow

    echo $APP_SSH_KEY | base64 -d > ~/.ssh/id_ed25519 (assuming you use ed25519 which is the default key)

    I would also advise moving away from docker in favor of podman since docker uses root by default

    Another approach could be pushing to the forgejo container registry and then setting your docker host to auto update

    • myrmidex@belgae.social
      link
      fedilink
      English
      arrow-up
      3
      ·
      19 hours ago

      pushing to the forgejo container registry and then setting your docker host to auto update

      This is what I prefer, with version tags instead of latest. Then I update the tag manually in the compose file and redeploy, but that could indeed easily be :latest+watchtower, full auto.