diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..d90a885 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build and push container image +on: + push: + branches: + - master +jobs: + build: + runs-on: ubuntu-22.04-node + steps: + - name: Install and setup Docker + run: | + apt update + apt install -y apt-transport-https ca-certificates curl gnupg lsb-release + curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo \ + "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ + $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null + apt update + apt install -y docker-ce docker-ce-cli containerd.io + - name: Checkout branch + uses: actions/checkout@v4.1.1 + - name: Login to Gitea + uses: docker/login-action@v3 + with: + registry: git.toast-server.net + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build and push image + uses: docker/build-push-action@v5.1.0 + with: + context: . + file: Dockerfile + platforms: linux/amd64 + push: true + tags: git.toast-server.net/toast/kon:main + cache-from: type=registry,ref=git.toast-server.net/toast/kon:main + cache-to: type=inline diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..3555482 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,19 @@ +name: Deploy to host +on: + registry_package: + types: [published] +jobs: + deploy: + runs-on: ubuntu-22.04-node + steps: + - name: SSH into Docker Host + uses: appleboy/ssh-action@55dabf81b49d4120609345970c91507e2d734799 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + passphrase: ${{ secrets.SSH_PASSPHRASE }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.SSH_PORT }} + script: | + cd kon && docker compose pull && \ + docker compose up -d --remove-orphans && docker image prune -f