From 9a8076813b99d738e19acb0d87153aa1666163c7 Mon Sep 17 00:00:00 2001 From: Leander Furumo Date: Mon, 2 Nov 2026 22:47:58 +0100 Subject: [PATCH] ci: deploy through the restricted uiogaming-deploy script The old workflow ran docker compose in the repo folder, which failed because the containers belong to the server's top-level compose project. The deploy key can now only run /usr/local/bin/uiogaming-deploy (see UiO-Gaming/drift), so the workflow just passes the service name. Also adds manual runs and prevents overlapping deploys. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/deploy.yml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 370c4c7..23ec26c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,31 +4,29 @@ on: push: branches: - main + workflow_dispatch: -# Let a running deploy finish before the next one starts -concurrency: - group: deploy - cancel-in-progress: false +# Never run two deploys of this repo at the same time +concurrency: deploy jobs: - run_pull: + deploy: runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Set up SSH run: | install -m 600 -D /dev/null ~/.ssh/id_ed25519 echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 # This should be redundant but seems to do the trick. ssh-keyscan -H ${{ vars.SSH_HOST }} > ~/.ssh/known_hosts - # up --build builds the new image while the old container keeps serving, - # then swaps the container. Old images are pruned so they don't fill the disk - - name: Connect, pull, build and deploy - run: ssh ${{ secrets.SSH_USER }}@${{ vars.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ vars.MAIN_BRANCH }} && git pull && docker compose up -d --build && docker image prune -f && exit" + # The deploy key can only run /usr/local/bin/uiogaming-deploy on the server. It takes the + # service name from the top-level docker-compose.yml (see drift/driftsdokumentasjon.md). + - name: Deploy + run: ssh ${{ secrets.SSH_USER }}@${{ vars.SSH_HOST }} uiogaming.no - name: Clean up + if: always() run: rm -rf ~/.ssh - - permissions: - contents: read