62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
name: Docker Build & Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: host
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
echo "Current workspace: $(pwd)"
|
|
|
|
# Clone the repository since Gitea runner doesn't auto-checkout
|
|
echo "Cloning repository..."
|
|
git clone https://gitea.skalas.org/jskala/NFOguard.git /tmp/repo
|
|
cp -r /tmp/repo/* .
|
|
cp -r /tmp/repo/.* . 2>/dev/null || true
|
|
rm -rf /tmp/repo
|
|
|
|
echo "Repository cloned successfully"
|
|
ls -la
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
echo "Building Docker image..."
|
|
docker build -t nfoguard:latest .
|
|
docker tag nfoguard:latest nfoguard:${{ github.sha }}
|
|
echo "Docker image built successfully"
|
|
|
|
- name: Push to registry (if main branch)
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
echo "Pushing Docker image to registry..."
|
|
# Add your registry push commands here
|
|
# Examples:
|
|
# docker tag nfoguard:latest your-registry.com/nfoguard:latest
|
|
# docker push your-registry.com/nfoguard:latest
|
|
# docker push your-registry.com/nfoguard:${{ github.sha }}
|
|
echo "Image ready for deployment"
|
|
|
|
deploy:
|
|
needs: build
|
|
runs-on: host
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Deploy application
|
|
run: |
|
|
echo "Deploying application..."
|
|
# Add your deployment commands here
|
|
# Examples:
|
|
# docker-compose pull
|
|
# docker-compose up -d
|
|
# or
|
|
# docker stop nfoguard || true
|
|
# docker run -d --name nfoguard -p 8080:8080 nfoguard:latest
|
|
echo "Deployment completed" |