From 0795daba4b8a7cec18e62055ed8dae0548a0f7a2 Mon Sep 17 00:00:00 2001 From: Owen Date: Sat, 11 Jul 2026 21:43:49 +0200 Subject: [PATCH] add production workflow --- .github/workflows/production.yml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/production.yml diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml new file mode 100644 index 0000000..c4dfbe6 --- /dev/null +++ b/.github/workflows/production.yml @@ -0,0 +1,53 @@ +name: Production Deploy + +on: + push: + branches: [main] + +env: + REGISTRY: ghcr.io + GH_USER: therealowenrees + IMAGE_NAME: therealowenrees/chess-scribe:latest + +jobs: + publish: + name: publish image + runs-on: ubuntu-24.04 + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Login to Github Container Registry + run: echo "${{ secrets.GHCR_SECRET }}" | docker login ghcr.io -u ${{ env.GH_USER }} --password-stdin + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build image and publish with Cache + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + cache-from: type=gha + cache-to: type=gha,mode=max + + deploy: + needs: publish + name: deploy image + runs-on: ubuntu-24.04 + + steps: + - name: Connect and pull image from GHCR + uses: appleboy/ssh-action@v1.2.5 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.PORT }} + script: | + cd /home/${{ secrets.USERNAME }} + echo "${{ secrets.GHCR_SECRET }}" | docker login ghcr.io -u ${{ env.GH_USER }} --password-stdin + docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + docker compose up -d \ No newline at end of file