Skip to content

๐Ÿฉน everyteen-cd.yml ํŒŒ์ผ ์ œ๊ฑฐ #3

๐Ÿฉน everyteen-cd.yml ํŒŒ์ผ ์ œ๊ฑฐ

๐Ÿฉน everyteen-cd.yml ํŒŒ์ผ ์ œ๊ฑฐ #3

name: everyteen-be-app CI/CD
on:
push:
branches: [ "develop" ]
paths-ignore: # ์ด ๊ฒฝ๋กœ์˜ ํŒŒ์ผ๋“ค์ด ๋ณ€๊ฒฝ๋˜๋ฉด ํŠธ๋ฆฌ๊ฑฐ๋˜์ง€ ์•Š์Œ
- ".github/*"
- "docs/readme.md"
pull_request:
branches: [ "develop" ]
paths-ignore: # ์ด ๊ฒฝ๋กœ์˜ ํŒŒ์ผ๋“ค์ด ๋ณ€๊ฒฝ๋˜๋ฉด ํŠธ๋ฆฌ๊ฑฐ๋˜์ง€ ์•Š์Œ
- ".github/*"
- "docs/readme.md"
env:
REGISTRY: docker.io
IMAGE_NAME: be-everyteen-app
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: โฌ†๏ธ Checkout repository # ๋Ÿฌ๋„ˆ ํ™˜๊ฒฝ์—์„œ develop ๋ธŒ๋žœ์น˜์˜ ์ฝ”๋“œ๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋‹จ๊ณ„
uses: actions/checkout@v4
- name: ๐Ÿ”ฐ Log in to Docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: โš™๏ธ Set up QEMU # ๋ฉ€ํ‹ฐ ์•„ํ‚คํ…์ณ ์ง€์› (ARM, x86_)
uses: docker/setup-buildx-action@v3
- name: โš’๏ธ Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
deploy:
runs-on: ubuntu-latest
environment: dev
needs: build-and-push-image # build-and-push-image job์ด ์„ฑ๊ณตํ•ด์•ผ๋งŒ ์‹คํ–‰
steps:
- name: ๐Ÿ”‘ executing remote ssh && deploy with docker-compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST_NAME }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
cd ${{ secrets.DOCKER_COMPOSE_PATH }}
docker-compose down
docker-compose up -d
docker image prune -f
docker ps -a