From 6d4a174ff480a05d5ce674059635772827cb06d9 Mon Sep 17 00:00:00 2001 From: Samuel Nishimwe Date: Tue, 3 Dec 2024 14:56:12 +0200 Subject: [PATCH] Pipeline envs (#163) * fix: remove the rm step * test: run on PR * test: test pusher cluster env * fix: add notification envs * test: add pusher key * fix: add the pusher app key * fix: log container start output * fix: remove the e flag * fix: revert changes * fix: re-add the pusher app key * fix: add pusher app key value * fix: typo * fix: test env file * fix: syntax * fix: remove the env from run cmd * fix: revert changes * fix: revert changes * fix: wrap run cmd in an if statement * Revert "test: test pusher cluster env" This reverts commit 57b2bbe4660885f8ba6b82679012950953c906c8. * test: create env file * test: add error handling --- .github/workflows/docker-image.yml | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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