-
Notifications
You must be signed in to change notification settings - Fork 3
57 lines (45 loc) · 1.71 KB
/
be-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
56
57
name: froxy BE Continuous Delivery
on:
push:
branches:
- deploy
jobs:
be-cd:
runs-on: ubuntu-20.04 # 빌드가 진행될 환경 설정
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }} # DockerHub 사용자 이름
password: ${{ secrets.DOCKER_PASSWORD }} # DockerHub 비밀번호
#이미지 이름 저장
- name: Set Docker image tag as a variable
run: echo "DOCKER_TAG=${{ secrets.DOCKER_USERNAME }}/froxy-server:latest" >> $GITHUB_ENV
- name: Create .env file
run: |
echo "${{ secrets.BE_ENV }}" > ./apps/backend/.env
- name: Build Docker image
run: |
docker build -t $DOCKER_TAG .
- name: Push Docker image to Docker Hub
run: |
docker push $DOCKER_TAG
- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy
run: |
ssh -o StrictHostKeyChecking=no mun@211.188.48.24 "
if [ \$(docker ps -a -q -f name=froxy-container) ]; then
docker stop froxy-container
docker rm froxy-container
fi
docker pull ${{ secrets.DOCKER_USERNAME }}/froxy-server:latest && \
docker run --network host -d --name froxy-container -v /var/run/docker.sock:/var/run/docker.sock ${{ secrets.DOCKER_USERNAME }}/froxy-server:latest
docker image prune -f
"