74 lines
2.2 KiB
YAML
74 lines
2.2 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)"
|
|
|
|
# Clean workspace first
|
|
rm -rf * .git* 2>/dev/null || true
|
|
|
|
# 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
|
|
echo "Checking Dockerfile:"
|
|
head -30 Dockerfile
|
|
|
|
- name: Check Docker availability
|
|
run: |
|
|
echo "Checking Docker installation..."
|
|
which docker || (echo "Docker not found in PATH" && exit 1)
|
|
docker --version || (echo "Docker not available" && exit 1)
|
|
docker info || (echo "Docker daemon not running" && exit 1)
|
|
|
|
- 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" |