Skip to content

fix: disable ESLint plugin during production build #9

fix: disable ESLint plugin during production build

fix: disable ESLint plugin during production build #9

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
BACKEND_DIR: App_Docker_Compose/backend/provedcode-backend-vitya199909
FRONTEND_DIR: App_Docker_Compose/frontend/provedcode-frontend-vitya199909
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_ZONE: europe-west1-b
jobs:
build-backend:
name: Build Backend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
working-directory: ${{ env.BACKEND_DIR }}
run: mvn clean package -DskipTests
- name: Run tests
working-directory: ${{ env.BACKEND_DIR }}
run: mvn test
- name: Upload backend artifact
uses: actions/upload-artifact@v4
with:
name: backend-jar
path: ${{ env.BACKEND_DIR }}/target/*.jar
retention-days: 1
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
- name: Debug - List files
run: |
echo "Current directory:"
pwd
echo "Frontend directory contents:"
ls -la ${{ env.FRONTEND_DIR }}/ || echo "Directory not found"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
working-directory: ${{ env.FRONTEND_DIR }}
run: npm ci
- name: Build frontend
working-directory: ${{ env.FRONTEND_DIR }}
run: DISABLE_ESLINT_PLUGIN=true npm run build
- name: Create archive
working-directory: ${{ env.FRONTEND_DIR }}
run: tar -czf frontend-build.tar.gz build/
- name: Upload frontend artifact
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: ${{ env.FRONTEND_DIR }}/frontend-build.tar.gz
retention-days: 1
deploy:
name: Deploy to GCP
needs: [build-backend, build-frontend]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.SUBMODULE_TOKEN }}
- name: Download backend artifact
uses: actions/download-artifact@v4
with:
name: backend-jar
path: ./artifacts/backend
- name: Download frontend artifact
uses: actions/download-artifact@v4
with:
name: frontend-build
path: ./artifacts/frontend
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure GCP Project
run: gcloud config set project ${{ env.GCP_PROJECT_ID }}
- name: Configure SSH
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H $(gcloud compute instances describe provedcode-backend --zone=${{ env.GCP_ZONE }} --format='get(networkInterfaces[0].accessConfigs[0].natIP)') >> ~/.ssh/known_hosts
ssh-keyscan -H $(gcloud compute instances describe provedcode-frontend --zone=${{ env.GCP_ZONE }} --format='get(networkInterfaces[0].accessConfigs[0].natIP)') >> ~/.ssh/known_hosts
- name: Install Ansible
run: |
sudo apt-get update
sudo apt-get install -y ansible
- name: Export Terraform outputs
working-directory: Terraform
run: |
# Get IPs from GCP instead of Terraform
echo "BACKEND_IP=$(gcloud compute instances describe provedcode-backend --zone=${{ env.GCP_ZONE }} --format='get(networkInterfaces[0].accessConfigs[0].natIP)')" >> $GITHUB_ENV
echo "FRONTEND_IP=$(gcloud compute instances describe provedcode-frontend --zone=${{ env.GCP_ZONE }} --format='get(networkInterfaces[0].accessConfigs[0].natIP)')" >> $GITHUB_ENV
echo "BACKEND_INTERNAL_IP=$(gcloud compute instances describe provedcode-backend --zone=${{ env.GCP_ZONE }} --format='get(networkInterfaces[0].networkIP)')" >> $GITHUB_ENV
echo "DB_HOST=${{ secrets.DB_HOST }}" >> $GITHUB_ENV
echo "DB_NAME=${{ secrets.DB_NAME }}" >> $GITHUB_ENV
echo "DB_USER=${{ secrets.DB_USER }}" >> $GITHUB_ENV
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> $GITHUB_ENV
- name: Deploy Backend
working-directory: Ansible
env:
ARTIFACT_PATH: ../artifacts/backend/provedcode-backend-vitya199909-0.0.1-SNAPSHOT.jar
run: |
ansible-playbook playbooks/deploy-backend.yml
- name: Deploy Frontend
working-directory: Ansible
env:
ARTIFACT_PATH: ../artifacts/frontend/frontend-build.tar.gz
run: |
ansible-playbook playbooks/deploy-frontend.yml
- name: Verify Deployment
run: |
echo "🚀 Deployment completed!"
echo "Frontend: http://${{ env.FRONTEND_IP }}"
echo "Backend: http://${{ env.BACKEND_IP }}:8080"
# Health check
sleep 10
curl -f http://${{ env.FRONTEND_IP }}/health || echo "⚠️ Frontend health check failed"
curl -f http://${{ env.BACKEND_IP }}:8080/actuator/health || echo "⚠️ Backend health check failed"
notify:
name: Notify Deployment Status
needs: [deploy]
runs-on: ubuntu-latest
if: always()
steps:
- name: Deployment Success
if: needs.deploy.result == 'success'
run: |
echo "✅ Deployment successful!"
- name: Deployment Failed
if: needs.deploy.result == 'failure'
run: |
echo "❌ Deployment failed!"
exit 1