Skip to content

Update main.yml

Update main.yml #5

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- master
env:
IMAGE_NAME: muhammadahmed1127/instagram-clone
IMAGE_TAG: backend-1.0
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: muhammadahmed1127
password: 8b:9z6@Z5\)~
- name: Build Docker image
run: docker build -t $IMAGE_NAME:$IMAGE_TAG ./
- name: Push Docker image to Docker Hub
run: docker push $IMAGE_NAME:$IMAGE_TAG
deploy:
runs-on: ubuntu-20.04
needs: build
steps:
- name: SSH into server and deploy Docker image
uses: appleboy/ssh-action@master
with:
host: 64.23.160.144
username: root
key: ${{ secrets.SSH_KEY }}
# script: |
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# docker ps -aq | xargs docker stop | xargs docker rm
# docker run -d -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG