π κΈ°λ₯-μμ -μ΄μ-ν νλ¦Ώ.md μμ #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |