Skip to content

fix: don't exit on cmd failure #58

fix: don't exit on cmd failure

fix: don't exit on cmd failure #58

Workflow file for this run

name: Docker Build and Deploy
on:
pull_request:
branches:
- develop
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
MONGO_PROD_DB: ${{ secrets.MONGO_PROD_DB }}
FRONTEND_LINK: "https://applications.devpulse.org"
NODE_ENV: "production"
PUSHER_CLUSTER: ${{ secrets.PUSHER_CLUSTER }}
PUSHER_APP_ID: ${{ secrets.PUSHER_APP_ID }}
PUSHER_APP_KEY: ${{ secrets.PUSHER_KEY }}
PUSHER_APP_SECRET: ${{ secrets.PUSHER_APP_SECRET }}
DEVPULSE_EMAIL: ${{ secrets.DEVPULSE_EMAIL }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build and push Docker image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: ${{ secrets.DOCKER_HUB_USERNAME2 }}/atlp-devpulse-bn
tags: latest
registry: docker.io
username: ${{ secrets.DOCKER_HUB_USERNAME2 }}
password: ${{ secrets.DOCKER_HUB_PASSWORD2 }}
buildArgs: 'NODE_ENV=production, MONGO_PROD_DB="${{ secrets.MONGO_PROD_DB }}"'
- name: Deploy to DigitalOcean
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DO_HOST }}
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, PUSHER_CLUSTER
script: |
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
output=$( docker run -d \
-p 4008:3000 \
--env-file env \
${{ 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