Bump actions/checkout from 4 to 6 #114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Zappify CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| backend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Lint | |
| run: npm run lint | |
| - name: Run tests | |
| run: npm test | |
| - name: Build Docker image | |
| run: docker build -t zappify-backend . | |
| frontend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Lint | |
| run: npm run lint | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: backend | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| continue-on-error: true | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| if [ ! -d "/home/ubuntu/Zappify" ]; then | |
| git clone https://github.com/Mishra-coder/Zappify.git /home/ubuntu/Zappify | |
| fi | |
| cd /home/ubuntu/Zappify | |
| git pull origin main | |
| cd backend | |
| npm install --production | |
| pm2 restart zappify-backend || pm2 start server.js --name zappify-backend | |
| pm2 save |