refactor-findAllFriendsOfUser (#44) #49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |