-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (44 loc) · 1.52 KB
/
ci-cd.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
46
47
48
49
50
51
52
53
54
55
name: Frontend CI/CD
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build packages
run: yarn build --filter=./packages
- name: Build applications
run: |
yarn build --filter=user
yarn build --filter=admin
- name: Build and push Docker images
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker build -f apps/user/Dockerfile -t $DOCKER_USERNAME/user-app .
docker push $DOCKER_USERNAME/user-app
docker build -f apps/admin/Dockerfile -t $DOCKER_USERNAME/admin-app .
docker push $DOCKER_USERNAME/admin-app
- name: Deploy to EC2
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST_DOMAIN }}
username: ${{ secrets.HOST_USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
docker login -u "${{ secrets.DOCKER_USERNAME }}" -p "${{ secrets.DOCKER_PASSWORD }}"
docker pull ${{ secrets.DOCKER_USERNAME }}/user-app
docker pull ${{ secrets.DOCKER_USERNAME }}/admin-app
docker-compose down
docker-compose up -d
docker image prune -a -f