update
This commit is contained in:
+27
-71
@@ -1,4 +1,4 @@
|
|||||||
name: CI/CD Pipeline
|
name: Docker Build & Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,15 +7,13 @@ on:
|
|||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
build:
|
||||||
runs-on: host
|
runs-on: host
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
run: |
|
||||||
echo "Current workspace: $(pwd)"
|
echo "Current workspace: $(pwd)"
|
||||||
echo "Available files:"
|
|
||||||
ls -la
|
|
||||||
|
|
||||||
# Clone the repository since Gitea runner doesn't auto-checkout
|
# Clone the repository since Gitea runner doesn't auto-checkout
|
||||||
echo "Cloning repository..."
|
echo "Cloning repository..."
|
||||||
@@ -24,83 +22,41 @@ jobs:
|
|||||||
cp -r /tmp/repo/.* . 2>/dev/null || true
|
cp -r /tmp/repo/.* . 2>/dev/null || true
|
||||||
rm -rf /tmp/repo
|
rm -rf /tmp/repo
|
||||||
|
|
||||||
echo "After checkout:"
|
echo "Repository cloned successfully"
|
||||||
ls -la
|
ls -la
|
||||||
echo "Backend directory:"
|
|
||||||
ls -la backend/ 2>/dev/null || echo "backend directory not found"
|
|
||||||
echo "Frontend directory:"
|
|
||||||
ls -la frontend/ 2>/dev/null || echo "frontend directory not found"
|
|
||||||
|
|
||||||
- name: Check Node.js version
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
which node || echo "Node.js not found in PATH"
|
echo "Building Docker image..."
|
||||||
node --version || echo "Node.js not available"
|
docker build -t nfoguard:latest .
|
||||||
which npm || echo "npm not found in PATH"
|
docker tag nfoguard:latest nfoguard:${{ github.sha }}
|
||||||
npm --version || echo "npm not available"
|
echo "Docker image built successfully"
|
||||||
|
|
||||||
- name: Install backend dependencies
|
- name: Push to registry (if main branch)
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
run: |
|
run: |
|
||||||
if [ -d "backend" ]; then
|
echo "Pushing Docker image to registry..."
|
||||||
cd backend
|
# Add your registry push commands here
|
||||||
npm ci
|
# Examples:
|
||||||
else
|
# docker tag nfoguard:latest your-registry.com/nfoguard:latest
|
||||||
echo "Backend directory not found, skipping backend dependencies"
|
# docker push your-registry.com/nfoguard:latest
|
||||||
exit 1
|
# docker push your-registry.com/nfoguard:${{ github.sha }}
|
||||||
fi
|
echo "Image ready for deployment"
|
||||||
|
|
||||||
- name: Run backend tests
|
|
||||||
env:
|
|
||||||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/nfoguard_test
|
|
||||||
JWT_SECRET: test-secret-key-for-ci
|
|
||||||
NODE_ENV: test
|
|
||||||
run: |
|
|
||||||
if [ -d "backend" ]; then
|
|
||||||
cd backend
|
|
||||||
npm run test
|
|
||||||
else
|
|
||||||
echo "Backend directory not found, skipping backend tests"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install frontend dependencies
|
|
||||||
run: |
|
|
||||||
if [ -d "frontend" ]; then
|
|
||||||
cd frontend
|
|
||||||
npm ci
|
|
||||||
else
|
|
||||||
echo "Frontend directory not found, skipping frontend dependencies"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run frontend tests
|
|
||||||
run: |
|
|
||||||
if [ -d "frontend" ]; then
|
|
||||||
cd frontend
|
|
||||||
npm run test
|
|
||||||
else
|
|
||||||
echo "Frontend directory not found, skipping frontend tests"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build frontend
|
|
||||||
run: |
|
|
||||||
if [ -d "frontend" ]; then
|
|
||||||
cd frontend
|
|
||||||
npm run build
|
|
||||||
else
|
|
||||||
echo "Frontend directory not found, skipping frontend build"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: test
|
needs: build
|
||||||
runs-on: host
|
runs-on: host
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy application
|
- name: Deploy application
|
||||||
run: |
|
run: |
|
||||||
echo "Deploying to production..."
|
echo "Deploying application..."
|
||||||
echo "Current directory: $(pwd)"
|
# Add your deployment commands here
|
||||||
echo "Available files:"
|
# Examples:
|
||||||
ls -la
|
# 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"
|
||||||
Reference in New Issue
Block a user