Skip to content

πŸ› κΈ°λŠ₯-μˆ˜μ •-이슈-ν…œν”Œλ¦Ώ.md μˆ˜μ • #14

πŸ› κΈ°λŠ₯-μˆ˜μ •-이슈-ν…œν”Œλ¦Ώ.md μˆ˜μ •

πŸ› κΈ°λŠ₯-μˆ˜μ •-이슈-ν…œν”Œλ¦Ώ.md μˆ˜μ • #14

Workflow file for this run

name: moongch-be-app CI/CD
on:
push:
branches: [ "develop" ]
paths-ignore: # 이 경둜의 νŒŒμΌλ“€μ΄ λ³€κ²½λ˜λ©΄ νŠΈλ¦¬κ±°λ˜μ§€ μ•ŠμŒ
- ".github/*"
- "docs/readme.md"
pull_request:
branches: [ "develop" ]
paths-ignore:
- ".github/*"
- "docs/readme.md"
types: [ opened, synchronize, reopened, closed ] # PR의 μƒνƒœ λ³€κ²½ 이벀트
env:
REGISTRY: docker.io
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 }}/${{ vars.DOCKER_IMAGE_NAME }}:latest
deploy:
if: ${{ github.event.pull_request.merged == true && github.event_name == 'pull_request' }}
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: ${{ vars.FULL_DOMAIN_NAME }}
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ vars.DOCKER_IMAGE_NAME }}:latest
cd ${{ secrets.DOCKER_COMPOSE_PATH }}
docker-compose down
docker-compose up -d
docker image prune -f
docker ps -a