-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (37 loc) · 1.25 KB
/
deploy.yml
File metadata and controls
46 lines (37 loc) · 1.25 KB
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
46
name: CI/CD Pipeline
on:
push:
branches:
- main
paths:
- 'backend/**'
- 'frontend/**'
- 'docker-compose.yml'
- '.github/workflows/**'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: Build backend image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/mean-backend:latest ./backend
- name: Build frontend image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/mean-frontend:latest ./frontend
- name: Push backend image
run: docker push ${{ secrets.DOCKER_USERNAME }}/mean-backend:latest
- name: Push frontend image
run: docker push ${{ secrets.DOCKER_USERNAME }}/mean-frontend:latest
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd mean-app
docker compose pull
docker compose down
docker compose up -d