File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches :
6+ - ms/Scrun-130-Project-Deployment-dockerfiles
7+
8+ jobs :
9+ test :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout Code
14+ uses : actions/checkout@v3
15+
16+ - name : Install Node.js
17+ uses : actions/setup-node@v3
18+ with :
19+ node-version : 18
20+
21+ - name : Install Dependencies
22+ run : npm install
23+
24+ - name : Run Tests
25+ run : npm test
26+
27+ deploy :
28+ needs : test
29+ runs-on : ubuntu-latest
30+
31+ steps :
32+ - name : Checkout Code
33+ uses : actions/checkout@v3
34+
35+ - name : Setup SSH Connection
36+ run : |
37+ echo "${{ secrets.GCP_SSH_PRIVATE_KEY }}" > private_key
38+ chmod 600 private_key
39+
40+ - name : Deploy to Google Cloud VM
41+ run : |
42+ ssh -i private_key -o StrictHostKeyChecking=no ${{ secrets.GCP_USERNAME }}@${{ secrets.GCP_VM_IP }} << 'EOF'
43+ cd /var/www/myapp || (mkdir -p /var/www/myapp && cd /var/www/myapp)
44+ git pull origin ms/Scrun-130-Project-Deployment-dockerfiles
45+ docker-compose down
46+ docker-compose build
47+ docker-compose up -d --remove-orphans
48+ EOF
You can’t perform that action at this time.
0 commit comments