-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (63 loc) ยท 2.06 KB
/
frontend-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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: "frontend-docker-build"
on:
push:
branches: [ "dev-fe" ]
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# ๋
ธ๋ ๋ฒ์ ์ค์ ๋ฐ ์์กด์ฑ ์ค์น
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18.17.1'
- name: Corepack Enable
run: corepack enable
- name: Install Dependencies
run: yarn install
- name: Create .env file
run: echo "NEXT_PUBLIC_API_HOST=${{ secrets.NEXT_PUBLIC_API_HOST }}" > packages/frontend/.env
- name: Build
run: |
cd packages/frontend
yarn build
docker:
name: Deploy Docker Image
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
file: ./packages/frontend/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/git-challenge-frontend:0.1
deploy:
name: Deploy Frontend
runs-on: ubuntu-latest
needs: docker
steps:
- name: SSH and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BACKEND_SSH_HOST }}
username: ${{ secrets.BACKEND_SSH_USERNAME }}
password: ${{ secrets.BACKEND_SSH_PASSWORD }}
port: ${{ secrets.BACKEND_SSH_PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/git-challenge-frontend:0.1
docker rm -f frontend || true
docker run -d --name frontend -p 3000:3000 \
-e NEXT_PUBLIC_API_HOST=${{ secrets.NEXT_PUBLIC_API_HOST }} \
${{ secrets.DOCKERHUB_USERNAME }}/git-challenge-frontend:0.1