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