From 9e313f5b860ea0de3263eb7456493e20177da005 Mon Sep 17 00:00:00 2001 From: sokol Date: Fri, 20 Feb 2026 13:55:53 +0300 Subject: [PATCH] feat: native deploy workflow without SSH --- .gitea/workflows/README.md | 39 +++++++++---------- .gitea/workflows/deploy.yml | 74 ++++++++++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 32 deletions(-) diff --git a/.gitea/workflows/README.md b/.gitea/workflows/README.md index 274b1aa..40b2711 100644 --- a/.gitea/workflows/README.md +++ b/.gitea/workflows/README.md @@ -32,18 +32,19 @@ **Triggers:** Push to `main` branch **Jobs:** -- SSH to deployment server -- Pull latest code -- Update Docker containers -- Clean up old images +- Build React application +- Build Docker image locally +- Create docker-compose.yml configuration +- Deploy container on Gitea runner (port 11088) +- Health check to verify application is running +- Cleanup old Docker images -**Required Secrets:** -- `DEPLOY_HOST` - Server hostname/IP -- `DEPLOY_USERNAME` - SSH username -- `DEPLOY_KEY` - SSH private key +**No SSH required** - Everything runs natively on the Gitea Actions runner! -**Optional Secrets:** -- `DEPLOY_PORT` - SSH port (default: 22) +**Output:** +- Application available at: `http://:11088` +- Container auto-restarts on failure +- Health check ensures successful deployment ## Setup Instructions @@ -54,18 +55,18 @@ Make sure Actions is enabled in your Gitea instance: ENABLED = true ``` -### 2. Configure Secrets -Go to your repository → Settings → Secrets and add: +### 2. Configure Runner +Ensure your Gitea runner has Docker and docker-compose installed: -**For Deployment:** -``` -DEPLOY_HOST=your-server.com -DEPLOY_USERNAME=deploy -DEPLOY_KEY= -DEPLOY_PORT=22 +```bash +# Install Docker +curl -fsSL https://get.docker.com | sh + +# Install docker-compose +sudo apt-get install docker-compose-plugin ``` -**No Docker secrets needed** - images are built locally and downloaded as artifacts! +**No secrets required** - Everything runs on the runner! ## Workflow Files Location `.gitea/workflows/` diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 0a34967..bc54480 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -8,21 +8,69 @@ on: jobs: deploy: runs-on: ubuntu-latest - + steps: - name: Checkout code uses: actions/checkout@v4 - - name: Deploy via SSH - uses: appleboy/ssh-action@v1.0.3 + - name: Setup Node.js + uses: actions/setup-node@v4 with: - host: ${{ secrets.DEPLOY_HOST }} - username: ${{ secrets.DEPLOY_USERNAME }} - key: ${{ secrets.DEPLOY_KEY }} - port: ${{ secrets.DEPLOY_PORT || 22 }} - script: | - cd /opt/configucci - git pull origin main - docker-compose pull - docker-compose up -d - docker system prune -f + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build application + run: npm run build + + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: false + load: true + tags: configucci:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Create docker-compose.yml + run: | + cat > docker-compose.yml << 'EOF' + version: '3.8' + services: + configucci: + image: configucci:latest + container_name: configucci + ports: + - "11088:80" + restart: unless-stopped + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:80"] + interval: 30s + timeout: 10s + retries: 3 + EOF + + - name: Stop existing containers + run: docker-compose down || true + + - name: Start new container + run: docker-compose up -d + + - name: Wait for application health + run: | + echo "Waiting for application to be healthy..." + for i in {1..30}; do + if curl -s http://localhost:11088 > /dev/null 2>&1; then + echo "Application is ready!" + exit 0 + fi + sleep 2 + done + echo "Application failed to start" + exit 1 + + - name: Cleanup old images + run: docker system prune -f