-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (49 loc) · 1.6 KB
/
deploy.yaml
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
name: Deploy
on:
push:
branches:
- main
- fix/design
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js environment
uses: actions/[email protected]
- name: Checkout
uses: actions/checkout@v3
- name: Log in to the Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Create .env file
run: |
echo "NEXT_PUBLIC_KAKAO_MAP_API_KEY=${{secrets.KAKAO_MAP_API_KEY}}" > .env.local
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: '.'
push: true
tags: |
ghcr.io/wafflestudio/csereal_nextjs_image:latest
ghcr.io/wafflestudio/csereal_nextjs_image:${{github.sha}}
- name: 'Prepare deploy key'
run: |
echo "${{secrets.SSH_KEY}}" > deploy_key
chmod 600 ./deploy_key
- name: 'Remote server commands'
uses: 'nick-fields/retry@v2'
with:
timeout_minutes: 1
max_attempts: 5
retry_wait_seconds: 1
retry_on: 'error'
command: |
ssh -T -i ./deploy_key -p 22 waffle@${{ secrets.SSH_HOST }}
docker ps
docker stop csereal_nextjs_image
docker rm csereal_nextjs_image
docker pull ghcr.io/wafflestudio/csereal_nextjs_image:latest
docker run -d -p 3000:3000 --name csereal_nextjs_image ghcr.io/wafflestudio/csereal_nextjs_image