Skip to content

Commit a83080a

Browse files
์‹ ์œค์ง„์‹ ์œค์ง„
authored andcommitted
๐Ÿ’š ci: Github actions
1 parent b39a6f6 commit a83080a

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI/CD (Docker)
2+
3+
on:
4+
push:
5+
branches: [ "develop" ]
6+
pull_request:
7+
branches: [ "develop" ]
8+
9+
jobs:
10+
docker:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
# Buildx
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
# Docker Hub ๋กœ๊ทธ์ธ (ํ† ํฐ ์‚ฌ์šฉ)
22+
- name: Login to Docker Hub
23+
if: github.event_name == 'push'
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
# ์ด๋ฏธ์ง€ ๋นŒ๋“œ (PR์—์„  push:false), develop ํ‘ธ์‹œ ์‹œ push:true
30+
- name: Build (PR)
31+
if: github.event_name == 'pull_request'
32+
uses: docker/build-push-action@v5
33+
with:
34+
context: .
35+
push: false
36+
tags: ${{ secrets.DOCKER_USERNAME }}/dogcat:pr-${{ github.event.pull_request.number }}
37+
cache-from: type=gha
38+
cache-to: type=gha,mode=max
39+
40+
- name: Build & Push (develop)
41+
if: github.event_name == 'push'
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
push: true
46+
tags: |
47+
${{ secrets.DOCKER_USERNAME }}/dogcat:dev
48+
${{ secrets.DOCKER_USERNAME }}/dogcat:${{ github.sha }}
49+
cache-from: type=gha
50+
cache-to: type=gha,mode=max
51+
52+
deploy:
53+
needs: docker
54+
runs-on: ubuntu-latest
55+
if: github.event_name == 'push'
56+
steps:
57+
- name: Deploy to Server
58+
uses: appleboy/ssh-action@v1.2.0
59+
with:
60+
host: ${{ secrets.SERVER_HOST }}
61+
username: ${{ secrets.SERVER_USER }}
62+
key: ${{ secrets.SERVER_SSH_KEY }}
63+
script: |
64+
cd ~/dogcat
65+
docker compose -f docker-compose-dev.yml --env-file .env.dev pull
66+
docker compose -f docker-compose-dev.yml --env-file .env.dev up -d --build

0 commit comments

Comments
ย (0)