✨ [FEAT] 홈 response 에 유저 닉네임 추가 #57
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: CI/CD using github actions & docker | |
on: | |
push: | |
branches: [ "dev" ] | |
permissions: | |
contents: read | |
jobs: | |
CI-CD: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. 리포지토리 코드 체크아웃 | |
- uses: actions/checkout@v3 | |
# 2. JDK 17 세팅 (빌드를 위해) | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 3. Gradle Caching | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# 4. application.yml 파일 생성 | |
- name: make application.yml | |
run: | | |
mkdir -p ./src/main/resources | |
cd ./src/main/resources | |
touch application.yml | |
echo "${{ secrets.YML }}" > application.yml | |
shell: bash | |
# 5. Gradle 빌드 (테스트 제외) | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
# 6. Set up Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# 7. Set up QEMU for multi-platform | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all | |
# 8. Docker 로그인 | |
- name: Docker Login | |
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
# 9. Docker 이미지 빌드 & 푸시 (multi-platform) | |
- name: Docker build & push | |
run: | | |
docker buildx build \ | |
--platform linux/amd64 \ | |
--push \ | |
-t ${{ secrets.DOCKER_USERNAME }}/with-suhyeon . | |
# 10. 원격 서버 배포 | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST_PROD }} | |
username: root | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
cd /root/with-suhyeon # docker-compose.yml 파일이 있는 폴더 | |
# 1) 혹시 실행중인 컨테이너 있으면 종료 | |
docker-compose down | |
# 2) 최신 이미지 pull | |
docker-compose pull | |
# 3) 백그라운드 실행 | |
docker-compose up -d --remove-orphans | |
# 4) 필요 시 사용 안 하는 이미지 정리 | |
docker image prune -f |