diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 01ee985..63e9d40 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,7 +1,7 @@ name: Docker Build and Deploy on: - push: + pull_request: branches: - develop @@ -14,7 +14,7 @@ jobs: NODE_ENV: "production" PUSHER_CLUSTER: ${{ secrets.PUSHER_CLUSTER }} PUSHER_APP_ID: ${{ secrets.PUSHER_APP_ID }} - PUSHER_APP_KEY: ${{ secrets.PUSHER_APP_KEY }} + PUSHER_APP_KEY: ${{ secrets.PUSHER_KEY }} PUSHER_APP_SECRET: ${{ secrets.PUSHER_APP_SECRET }} DEVPULSE_EMAIL: ${{ secrets.DEVPULSE_EMAIL }} @@ -41,29 +41,29 @@ jobs: username: ${{ secrets.DO_USERNAME }} key: ${{ secrets.DO_KEY }} port: ${{ secrets.DO_PORT }} - envs: MONGO_PROD_DB,REGISTER_FRONTEND_URL,REGISTER_ORG_FRONTEND_URL,NODE_ENV,FRONTEND_LINK,ADMIN_EMAIL,ADMIN_PASS,COORDINATOR_EMAIL,COORDINATOR_PASS,GH_TOKEN + envs: MONGO_PROD_DB,REGISTER_FRONTEND_URL,REGISTER_ORG_FRONTEND_URL,NODE_ENV,FRONTEND_LINK,ADMIN_EMAIL,ADMIN_PASS,COORDINATOR_EMAIL,COORDINATOR_PASS,GH_TOKEN, PUSHER_CLUSTER script: | - echo "MONGO_PROD_DB=${MONGO_PROD_DB}" > env - echo "FRONTEND_LINK=${FRONTEND_LINK}" >> env - echo "NODE_ENV=${NODE_ENV}" >> env - echo "PUSHER_CLUSTER=${PUSHER_CLUSTER}" >> env - echo "PUSHER_APP_ID=${PUSHER_APP_ID}" >> env - echo "PUSHER_APP_KEY=${PUSHER_APP_KEY}" >> env - echo "PUSHER_APP_SECRET=${PUSHER_APP_SECRET}" >> env - echo "DEVPULSE_EMAIL=${DEVPULSE_EMAIL}" >> env + set -e # Exit immediately if a command exits with a non-zero status + set -x # Print commands and their arguments as they are executed + touch env + echo "MONGO_PROD_DB=${MONGO_PROD_DB}" >> env # Pull the latest image docker pull ${{ secrets.DOCKER_HUB_USERNAME2 }}/atlp-devpulse-bn:latest # Stop and remove existing container if it exists docker stop $(docker ps -q --filter publish=4008) || true docker rm $(docker ps -aq --filter publish=4008) || true - # Run new container - docker run -d \ + output=$( docker run -d \ -p 4008:3000 \ --env-file env \ - ${{ secrets.DOCKER_HUB_USERNAME2 }}/atlp-devpulse-bn:latest + ${{ secrets.DOCKER_HUB_USERNAME2 }}/atlp-devpulse-bn:latest) + echo $output + + echo "Container ID: $output" + if [ -z "$output" ]; then + echo "Container failed to start" + exit 1 + fi - # Clean up - rm env