Skip to content

Continuous Deployment for User Service #53

Continuous Deployment for User Service

Continuous Deployment for User Service #53

Workflow file for this run

name: Continuous Deployment for User Service
on:
workflow_run:
workflows: ["Continuous Integration for User Service"]
types:
- completed
env:
K8S_NAMESPACE: default
jobs:
deploy:
name: Deploy to Private K8S Server
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
- name: Build the application
run: |
mvn clean
mvn -B package --file pom.xml
- name: Install OpenVPN
run: sudo apt-get update && sudo apt-get install -y openvpn
- name: Connect to VPN
env:
VPN_USERNAME: ${{ secrets.VPN_USERNAME }}
VPN_PASSWORD: ${{ secrets.VPN_PASSWORD }}
run: |
echo "${{ secrets.VPN_PROFILE_BASE64 }}" | base64 --decode > profile-559.ovpn
echo -e "${VPN_USERNAME}\n${VPN_PASSWORD}" > vpn-auth.txt
sudo openvpn --config profile-559.ovpn --auth-user-pass vpn-auth.txt --daemon
sleep 10
rm vpn-auth.txt
rm profile-559.ovpn
- name: Deploy to Server
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /home/ubuntu/K8S
sudo kubectl apply -f user-mongo-deployment.yaml
sudo kubectl apply -f user-service-deployment.yaml
# - name: Apply Kubernetes manifests
# run: |
# kubectl apply -f resources.yaml
notifications:
needs: deploy
uses: ./.github/workflows/notifyCD.yaml
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}