Skip to content

refactor-findAllFriendsOfUser (#44) #49

refactor-findAllFriendsOfUser (#44)

refactor-findAllFriendsOfUser (#44) #49

Workflow file for this run

name: CI/CD Docker
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy to Instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_HOST }}
username: ${{ secrets.AWS_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
sudo docker pull ${{ secrets.DOCKER_IMAGE }}:latest
EXISTING_CONTAINER=$(sudo docker ps --filter "publish=8080" -q)
if [ ! -z "$EXISTING_CONTAINER" ]; then
echo "Stopping and removing existing container on port 8080"
sudo docker stop $EXISTING_CONTAINER
sudo docker rm $EXISTING_CONTAINER
fi
sudo docker rm -f ${{ secrets.CONTAINER_NAME }} || true
sudo docker run -d -p 8080:8080 --name ${{ secrets.CONTAINER_NAME }} \
-e MYSQL_URL=${{ secrets.MYSQL_URL }} \
-e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} \
-e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} \
${{ secrets.DOCKER_IMAGE }}:latest
sudo docker system prune -f