Skip to content

Merge branch 'develop' #1

Merge branch 'develop'

Merge branch 'develop' #1

Workflow file for this run

name: otr-web staging deploy
on:
push:
branches: [ master ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
docker build -f DockerfileProd -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROD_DOCKER_IMAGE_NAME }}:latest .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROD_DOCKER_IMAGE_NAME }}:latest
deploy:
needs: publish
runs-on: ubuntu-latest
steps:
- name: Deploy to Production Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
docker pull '${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROD_DOCKER_IMAGE_NAME }}:latest'
docker stop '${{ secrets.PROD_DOCKER_IMAGE_NAME }}' || true
docker rm '${{ secrets.PROD_DOCKER_IMAGE_NAME }}' || true
docker run -d --name '${{ secrets.PROD_DOCKER_IMAGE_NAME }}' -p 3001:3000 --restart always \
'${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROD_DOCKER_IMAGE_NAME }}:latest'