Skip to content

added final project functionalities #23

added final project functionalities

added final project functionalities #23

Workflow file for this run

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"