Skip to content

Commit 431b7a3

Browse files
authored
๐Ÿ‹ chore: ๋ฐฑ์—”๋“œ ์†Œ์ผ“ ์„œ๋ฒ„ ๋นŒ๋“œ ์Šคํฌ๋ฆฝํŠธ ์ถ”๊ฐ€
1 parent 05d5605 commit 431b7a3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Backend Socket Server Deploy
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
docker-build-push:
9+
runs-on: ubuntu-latest
10+
defaults:
11+
run:
12+
working-directory: ./backend/socket
13+
14+
steps:
15+
- name: repository์˜ ํŒŒ์ผ์„ ๊ฐ€์ƒ ์ธ์Šคํ„ด์Šค๋กœ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.
16+
uses: actions/checkout@v3
17+
18+
- name: docker ๊ด€๋ จ ๋กœ์ง ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ buildx๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
19+
uses: docker/setup-buildx-action@v2
20+
21+
- name: docker hub์— ๋กœ๊ทธ์ธ ํ•ฉ๋‹ˆ๋‹ค.
22+
uses: docker/login-action@v2
23+
with:
24+
username: ${{ secrets.DOCKER_HUB_ID }}
25+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
26+
27+
- name: docker ์ด๋ฏธ์ง€๋ฅผ build ๋ฐ pushํ•ฉ๋‹ˆ๋‹ค.
28+
uses: docker/build-push-action@v3
29+
with:
30+
context: ./backend/socket
31+
push: true
32+
tags: ${{ secrets.DOCKER_SOCKET_IMAGE }}:${{ secrets.VERSION }}
33+
cache-from: type=gha
34+
cache-to: type=gha,mode=max
35+
36+
docker-run:
37+
needs: docker-build-push
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- name: ๋ฐฐํฌ ์„œ๋ฒ„์—์„œ docker image๋ฅผ ๋ฐ›์•„์„œ container๋ฅผ ์‹คํ–‰์‹œํ‚ต๋‹ˆ๋‹ค.
42+
uses: appleboy/ssh-action@master
43+
with:
44+
username: ${{ secrets.SOCKET_SERVER_USER }}
45+
password: ${{ secrets.SOCKET_SERVER_PWD }}
46+
host: ${{ secrets.SOCKET_SERVER_HOST }}
47+
port: ${{ secrets.SOCKET_SERVER_PORT }}
48+
49+
script: |
50+
export CURRENT_CONTAINER=$(docker ps -aq -f "name=socket-server")
51+
docker stop $(echo $CURRENT_CONTAINER) && docker rm $(echo $CURRENT_CONTAINER)
52+
docker pull ${{ secrets.DOCKER_SOCKET_IMAGE }}:${{ secrets.VERSION }}
53+
docker run --name socket-server --restart always -d -p 8081:8081 ${{ secrets.DOCKER_SOCKET_IMAGE }}:${{ secrets.VERSION }}

0 commit comments

Comments
ย (0)