Pipeline envs #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_KEY: ${{ secrets.PUSHER_KEY }} | |
PUSHER_SECRET: ${{ secrets.PUSHER_SECRET }} | |
DEVPULSE_EMAIL: ${{ secrets.DEVPULSE_EMAIL }} | |
CLOUDINARY_CLOUD_NAME: ${{ secrets.CLOUDINARY_CLOUD_NAME }} | |
CLOUDINARY_API_KEY: ${{ secrets.CLOUDINARY_API_KEY }} | |
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }} | |
Gnews_Api_Key: ${{ secrets.Gnews_Api_Key }} | |
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,FRONTEND_LINK,NODE_ENV,PUSHER_CLUSTER,PUSHER_APP_ID,PUSHER_KEY,PUSHER_SECRET,DEVPULSE_EMAIL,CLOUDINARY_CLOUD_NAME,CLOUDINARY_API_KEY,CLOUDINARY_API_SECRET,Gnews_Api_Key | |
script: | | |
docker pull ${{ secrets.DOCKER_HUB_USERNAME2 }}/atlp-devpulse-bn:latest | |
docker stop $(docker ps -q --filter publish=4008) || true | |
docker rm $(docker ps -aq --filter publish=4008) || true | |
docker run -d \ | |
-p 4008:3000 \ | |
-e MONGO_PROD_DB="${MONGO_PROD_DB}" \ | |
-e FRONTEND_LINK="${FRONTEND_LINK}" \ | |
-e NODE_ENV="production" \ | |
-e PUSHER_CLUSTER="${PUSHER_CLUSTER}" \ | |
-e PUSHER_APP_ID="${PUSHER_APP_ID}" \ | |
-e PUSHER_KEY="${PUSHER_KEY}" \ | |
-e PUSHER_SECRET="${PUSHER_SECRET}" \ | |
-e CLOUDINARY_CLOUD_NAME="${CLOUDINARY_CLOUD_NAME}" \ | |
-e CLOUDINARY_API_KEY="${CLOUDINARY_API_KEY}" \ | |
-e CLOUDINARY_API_SECRET="${CLOUDINARY_API_SECRET}" \ | |
${{ secrets.DOCKER_HUB_USERNAME2 }}/atlp-devpulse-bn:latest |