diff --git a/.github/workflows/backend-prod.yml b/.github/workflows/backend-prod.yml index 8a3d52e5..f2dfd66f 100644 --- a/.github/workflows/backend-prod.yml +++ b/.github/workflows/backend-prod.yml @@ -116,116 +116,116 @@ jobs: echo "Health check passed." - - name: Update or create Nginx container to point to new container port - run: | - NGINX_CONTAINER_NAME="nginx-proxy" - echo "Checking if Nginx container exists..." - if sudo docker ps -a --filter "name=$NGINX_CONTAINER_NAME" --format "{{.Names}}" | grep -w $NGINX_CONTAINER_NAME; then + port-switch: + needs: deploy + strategy: + matrix: + runner: [ prod-1 , prod-2 ] + runs-on: [ self-hosted, '${{ matrix.runner }}' ] + steps: + - name: Update or create Nginx container to point to new container port + run: | + NGINX_CONTAINER_NAME="nginx-proxy" + + echo "Checking if Nginx container exists..." + if sudo docker ps -a --filter "name=$NGINX_CONTAINER_NAME" --format "{{.Names}}" | grep -w $NGINX_CONTAINER_NAME; then + + # Check if the Nginx container is running + if sudo docker ps --filter "name=$NGINX_CONTAINER_NAME" --format "{{.Names}}" | grep -w $NGINX_CONTAINER_NAME; then + echo "Nginx container is running." + else + echo "Nginx container exists but is not running. Starting Nginx container..." + sudo docker start $NGINX_CONTAINER_NAME + echo "Nginx container started." + fi + + # Ensure nginx-conf directory and default.conf file exist + mkdir -p ./nginx-conf + + # Create or update the default.conf file with the new configuration + echo "Creating or updating default.conf..." + + cat > ./nginx-conf/default < ./nginx-conf/default.conf < ./nginx-conf/default < ./nginx-conf/default.conf <