name: Frontend CI/CD on: push: branches: [main] pull_request: branches: [main] permissions: contents: read jobs: build: runs-on: ubuntu-latest timeout-minutes: 20 env: NODE_VERSION: "20" VITE_API_BASE_URL: https://api.east-guilan-ce.ir steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} cache: npm cache-dependency-path: package-lock.json - name: Prepare environment file run: cp .env.sample .env - name: Install dependencies run: npm install --no-audit --no-fund - name: Run lint run: npm run lint - name: Build frontend run: npm run build deploy: runs-on: ubuntu-latest needs: build if: github.event_name == 'push' && github.ref == 'refs/heads/main' timeout-minutes: 30 steps: - name: Deploy frontend service uses: appleboy/ssh-action@v1.2.0 with: host: ${{ secrets.DEPLOY_HOST }} username: ${{ secrets.DEPLOY_USER }} key: ${{ secrets.DEPLOY_SSH_KEY }} port: ${{ secrets.DEPLOY_PORT }} script: | set -e cd "${{ secrets.DEPLOY_PATH }}/frontend/guilan-ace-frontend" git fetch --prune origin git checkout "${{ vars.FRONTEND_BRANCH || 'main' }}" git pull --ff-only origin "${{ vars.FRONTEND_BRANCH || 'main' }}" cd "${{ secrets.DEPLOY_PATH }}" docker compose up -d --build frontend docker image prune -f