-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (38 loc) · 1.18 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASS }}
- 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: 143.198.239.1
username: root
key: ${{ secrets.SSH_KEY }}
script: |
apt update && apt install docker.io -y
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASS }}
# docker ps -aq | xargs docker stop | xargs docker rm
docker run -d -p 5000:5000 muhammadahmed1127/instagram-clone:backend-1.0