diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml index f4fe11f..6f8b4f8 100644 --- a/.github/workflows/backend-deploy.yml +++ b/.github/workflows/backend-deploy.yml @@ -68,6 +68,7 @@ jobs: script: | CURRENT_STATE=$(curl -s http://${{ secrets.BLUE_GREEN_HOST }}:${{ secrets.BLUE_GREEN_PORT }}/status) echo "The current state is $CURRENT_STATE" + docker image prune -f docker pull ${{ secrets.DOCKERHUB_USERNAME }}/git-challenge-backend:0.1 if [ $CURRENT_STATE = "blue" ]; then docker run -d --name backend-green -p 8081:8080 \ @@ -111,9 +112,9 @@ jobs: password: ${{ secrets.NGINX_SSH_PASSWORD }} port: ${{ secrets.NGINX_SSH_PORT }} script: | - if [ $(cat /status) = "green" ]; then - sed -i 's/proxy_pass http:\/\/127.0.0.1:808[0-1];/proxy_pass http:\/\/127.0.0.1:8081;/' /etc/nginx/sites-available/default + if [ "$CURRENT_STATE" = "green" ]; then + sed -i 's/proxy_pass http:\/\/[a-zA-Z0-9\.\-]+:8080;/proxy_pass http:\/\/[a-zA-Z0-9\.\-]+:8081;/' /etc/nginx/sites-available/default else - sed -i 's/proxy_pass http:\/\/127.0.0.1:808[0-1];/proxy_pass http:\/\/127.0.0.1:8080;/' /etc/nginx/sites-available/default + sed -i 's/proxy_pass http:\/\/[a-zA-Z0-9\.\-]+:8081;/proxy_pass http:\/\/[a-zA-Z0-9\.\-]+:8080;/' /etc/nginx/sites-available/default fi sudo nginx -s reload \ No newline at end of file