-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (36 loc) · 1.22 KB
/
deploy.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
name: Build and Deploy to Docker Hub
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v3 # Clone the Repository
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./web/Dockerfile
push: true
tags: thinley44/dchat-web:latest # Replace with your Docker Hub username and repository
- name: Verify Pushed Image
run: docker pull thinley44/dchat-web:latest # Replace with your Docker Hub username and repository
- name: Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker pull thinley44/dchat-web:latest
sudo docker stop dchat-web || true
sudo docker rm dchat-web || true
sudo docker run -d --name dchat-web -p 3005:3000 thinley44/dchat-web:latest