CI/CD: Gitea workflow + docker-compose for Swarm
CI/CD Deploy / test (push) Successful in 1m7s
CI/CD Deploy / build-push (push) Successful in 1m45s
CI/CD Deploy / deploy (push) Successful in 57s

This commit is contained in:
Antoni Nuñez Romeu
2026-07-31 11:20:17 +02:00
parent e6b1bfe9a4
commit e54efb59ee
2 changed files with 61 additions and 7 deletions
+50 -7
View File
@@ -1,14 +1,56 @@
name: Deploy Docker container name: CI/CD Deploy
run-name: ${{ gitea.actor }} is deploying to PROD servers. run-name: ${{ gitea.actor }} is deploying to PROD servers.
on: [ push, fork, pull ] on:
push:
branches: [ main ]
jobs: jobs:
Deploy: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: SSH to remote server - name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Run tests
run: npm test
build-push:
needs: test
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: git.hacecalor.net
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
git.hacecalor.net/ichitux/zlb:latest
git.hacecalor.net/ichitux/zlb:${{ gitea.sha }}
- run: 'echo "Image ${{ gitea.sha }} pushed to registry. Job status: ${{ job.status }}"'
deploy:
needs: build-push
runs-on: ubuntu-latest
steps:
- name: SSH to remote server and update Swarm service
uses: appleboy/ssh-action@v1.0.3 uses: appleboy/ssh-action@v1.0.3
with: with:
host: ${{ secrets.HOST }} host: ${{ secrets.HOST }}
@@ -18,7 +60,8 @@ jobs:
script: | script: |
cd /home/zouklambadabcn.com/public_html/ cd /home/zouklambadabcn.com/public_html/
git pull git pull
docker compose down docker login git.hacecalor.net -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }}
docker compose up -d --build docker compose pull
docker stack deploy -c docker-compose.yml zlb
docker image prune -f docker image prune -f
- run: echo "🍏 This job's status is ${{ job.status }}." - run: 'echo "This job status is ${{ job.status }}"'
+11
View File
@@ -1,8 +1,19 @@
services: services:
zlb: zlb:
image: git.hacecalor.net/ichitux/zlb:latest
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
ports: ports:
- "35207:80" - "35207:80"
restart: unless-stopped restart: unless-stopped
deploy:
replicas: 1
update_config:
order: start-first
failure_action: rollback
restart_policy:
condition: any
placement:
constraints:
- node.role == manager