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
    0
    ·
    3 days ago

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

    1. Checkout the repo
    2. Build app
    3. Create SSH key
    4. 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

    • myrmidex@belgae.social
      link
      fedilink
      English
      arrow-up
      0
      ·
      3 days 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.