feat: native deploy workflow without SSH
This commit is contained in:
@@ -32,18 +32,19 @@
|
|||||||
**Triggers:** Push to `main` branch
|
**Triggers:** Push to `main` branch
|
||||||
|
|
||||||
**Jobs:**
|
**Jobs:**
|
||||||
- SSH to deployment server
|
- Build React application
|
||||||
- Pull latest code
|
- Build Docker image locally
|
||||||
- Update Docker containers
|
- Create docker-compose.yml configuration
|
||||||
- Clean up old images
|
- Deploy container on Gitea runner (port 11088)
|
||||||
|
- Health check to verify application is running
|
||||||
|
- Cleanup old Docker images
|
||||||
|
|
||||||
**Required Secrets:**
|
**No SSH required** - Everything runs natively on the Gitea Actions runner!
|
||||||
- `DEPLOY_HOST` - Server hostname/IP
|
|
||||||
- `DEPLOY_USERNAME` - SSH username
|
|
||||||
- `DEPLOY_KEY` - SSH private key
|
|
||||||
|
|
||||||
**Optional Secrets:**
|
**Output:**
|
||||||
- `DEPLOY_PORT` - SSH port (default: 22)
|
- Application available at: `http://<gitea-server>:11088`
|
||||||
|
- Container auto-restarts on failure
|
||||||
|
- Health check ensures successful deployment
|
||||||
|
|
||||||
## Setup Instructions
|
## Setup Instructions
|
||||||
|
|
||||||
@@ -54,18 +55,18 @@ Make sure Actions is enabled in your Gitea instance:
|
|||||||
ENABLED = true
|
ENABLED = true
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Configure Secrets
|
### 2. Configure Runner
|
||||||
Go to your repository → Settings → Secrets and add:
|
Ensure your Gitea runner has Docker and docker-compose installed:
|
||||||
|
|
||||||
**For Deployment:**
|
```bash
|
||||||
```
|
# Install Docker
|
||||||
DEPLOY_HOST=your-server.com
|
curl -fsSL https://get.docker.com | sh
|
||||||
DEPLOY_USERNAME=deploy
|
|
||||||
DEPLOY_KEY=<paste-ssh-private-key>
|
# Install docker-compose
|
||||||
DEPLOY_PORT=22
|
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
|
## Workflow Files Location
|
||||||
`.gitea/workflows/`
|
`.gitea/workflows/`
|
||||||
|
|||||||
@@ -8,21 +8,69 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Deploy via SSH
|
- name: Setup Node.js
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.DEPLOY_HOST }}
|
node-version: '20'
|
||||||
username: ${{ secrets.DEPLOY_USERNAME }}
|
cache: 'npm'
|
||||||
key: ${{ secrets.DEPLOY_KEY }}
|
|
||||||
port: ${{ secrets.DEPLOY_PORT || 22 }}
|
- name: Install dependencies
|
||||||
script: |
|
run: npm ci
|
||||||
cd /opt/configucci
|
|
||||||
git pull origin main
|
- name: Build application
|
||||||
docker-compose pull
|
run: npm run build
|
||||||
docker-compose up -d
|
|
||||||
docker system prune -f
|
- 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