git commit -m 'fixing workflow bugs' #6
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: ms/Scrun-130-Project-Deployment-dockerfiles | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Run frontend tests | |
| run: cd course-matrix/frontend && npm install && npm run test | |
| - name: Run backend tests | |
| run: cd course-matrix/backend && npm install && npm run test | |
| deploy: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v3 | |
| - name: Setup SSH Connection | |
| run: | | |
| echo "${{ secrets.GCP_SSH_PRIVATE_KEY }}" > private_key | |
| chmod 600 private_key | |
| - name: Deploy to Google Cloud VM | |
| run: | | |
| ssh -i private_key -o StrictHostKeyChecking=no ${{ secrets.GCP_USERNAME }}@${{ secrets.GCP_VM_IP }} << 'EOF' #this might be causing errors | |
| cd term-group-project-c01w25-project-course-matrix || { echo "Error: Directory /root/myapp does not exist!"; exit 1; } | |
| git pull origin ms/Scrun-130-Project-Deployment-dockerfiles | |
| cd course-matrix | |
| docker compose build | |
| docker compose up -d --remove-orphans | |
| EOF |