Skip to content

Commit ffea75a

Browse files
committed
Update deploymentCD.yaml
1 parent 71fe318 commit ffea75a

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

.github/workflows/deploymentCD.yaml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ name: Continuous Deployment for User Service
22

33
on:
44
workflow_run:
5-
workflows: ["Continuous Integration for Comment Service"]
5+
workflows: ["Continuous Integration for User Service"]
66
types:
77
- completed
88

99
env:
10-
PROJECT_ID: gke-project-423206
11-
CLUSTER_NAME: autopilot-cluster-1
12-
ZONE: us-central1
10+
K8S_NAMESPACE: default
1311

1412
jobs:
1513
deploy:
16-
name: Deploy to GKE Autopilot
14+
name: Deploy to Private K8S Server
1715
runs-on: ubuntu-latest
1816
steps:
1917
- name: Checkout code
@@ -30,27 +28,36 @@ jobs:
3028
mvn clean
3129
mvn -B package --file pom.xml
3230
33-
- name: Authenticate
34-
uses: google-github-actions/auth@v2
35-
with:
36-
credentials_json: ${{ secrets.GCP_SA_KEY }}
37-
38-
- name: Configure gcloud
39-
uses: google-github-actions/setup-gcloud@v2
40-
with:
41-
project_id: ${{ env.PROJECT_ID }}
42-
install_components: 'gke-gcloud-auth-plugin'
43-
44-
- name: Set cluster context
31+
- name: Install OpenVPN
32+
run: sudo apt-get update && sudo apt-get install -y openvpn
33+
34+
- name: Connect to VPN
35+
env:
36+
VPN_USERNAME: ${{ secrets.VPN_USERNAME }}
37+
VPN_PASSWORD: ${{ secrets.VPN_PASSWORD }}
4538
run: |
46-
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --zone ${{ env.ZONE }} --project ${{ env.PROJECT_ID }}
39+
echo -e "${VPN_USERNAME}\n${VPN_PASSWORD}" > vpn-auth.txt
40+
sudo openvpn --config profile-559.ovpn --auth-user-pass vpn-auth.txt --daemon
41+
sleep 10
42+
rm vpn-auth.txt
4743
48-
- name: Apply Kubernetes manifests
49-
run: |
50-
kubectl apply -f resources.yaml
51-
52-
notifications:
53-
needs: deploy
54-
uses: ./.github/workflows/notifyCD.yaml
55-
secrets:
56-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL}}
44+
- name: Deploy to Server
45+
uses: appleboy/[email protected]
46+
with:
47+
host: ${{ secrets.SERVER_HOST }}
48+
username: ${{ secrets.SERVER_USERNAME }}
49+
key: ${{ secrets.SERVER_SSH_KEY }}
50+
script: |
51+
cd /home/ubuntu/K8S
52+
kubectl apply -f user-mongo-deployment.yaml
53+
kubectl apply -f user-service-deployment.yaml
54+
55+
# - name: Apply Kubernetes manifests
56+
# run: |
57+
# kubectl apply -f resources.yaml
58+
59+
# notifications:
60+
# needs: deploy
61+
# uses: ./.github/workflows/notifyCD.yaml
62+
# secrets:
63+
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

0 commit comments

Comments
 (0)