-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (30 loc) · 1.08 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Deploy and Test Microservice
on:
push:
branches:
- main
jobs:
deploy-and-test:
runs-on: ubuntu-latest
steps:
- name: Set environment variable
run: |
echo "SERVER_IP=34.30.27.130" >> $GITHUB_ENV
echo "PORT=8011" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH key
env:
ssh_private_key: ${{ secrets.ssh_private_key }}
run: |
echo "$ssh_private_key" > ssh_private_key
chmod 600 ssh_private_key
ssh -i ssh_private_key -o StrictHostKeyChecking=no zc2737@$SERVER_IP "docker ps -q --filter status=running | xargs -r docker stop && docker run -d -p $PORT:$PORT ubuntu:ms1 sh -c 'cd ~/*CC* && git pull && pip3 install -r requirements.txt && python3 main.py $PORT'"
# eval "$(ssh-agent -s)"
# ssh-add ssh_private_key
- name: Wait for microservice to start
run: sleep 10s
- name: Retrieve content with curl
run: |
http_content=$(curl -s http://$SERVER_IP:$PORT/users)
echo "Retrieved Content: $http_content"