feat: native deploy workflow without SSH
This commit is contained in:
@@ -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://<gitea-server>: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=<paste-ssh-private-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/`
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user