Skip to content

Commit 226da1b

Browse files
committed
infra: CI/CD workflow 작성
1 parent d15304a commit 226da1b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/cicd.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ "dev" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/[email protected]
13+
14+
- name: Log in to Docker Hub
15+
uses: docker/[email protected]
16+
with:
17+
username: ${{ secrets.DOCKER_USERNAME }}
18+
password: ${{ secrets.DOCKER_PASSWORD }}
19+
20+
- name: Build and Push Docker image
21+
if: github.ref == 'refs/heads/dev'
22+
uses: docker/[email protected]
23+
with:
24+
context: .
25+
file: ./Dockerfile
26+
push: true
27+
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROD_IMAGE_NAME }}:latest
28+
platforms: linux/amd64
29+
30+
deploy:
31+
runs-on: ubuntu-latest
32+
needs: build
33+
34+
steps:
35+
- name: SSH to Server and Deploy
36+
if: github.ref == 'refs/heads/dev'
37+
uses: appleboy/[email protected]
38+
with:
39+
host: ${{ secrets.PROD_SERVER_HOST }}
40+
port: ${{ secrets.PROD_SERVER_PORT }}
41+
username: ${{ secrets.PROD_SERVER_USERNAME }}
42+
key: ${{ secrets.PROD_SERVER_KEY }}
43+
script: |
44+
cd /home/ubuntu/dasom
45+
mkdir -p ./env
46+
echo "${{ secrets.ENV }}" > ./env/prodEnv
47+
./deploy.sh

0 commit comments

Comments
 (0)