Update V4__add_column_review.sql #151
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: Build & Deploy | |
on: | |
push: | |
branches: [ "main" ] # main 브랜치에 push가 발생하면 workflow가 실행됩니다. | |
permissions: | |
contents: read # 권한을 설정합니다. | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
# set up java | |
steps: | |
- name: Checkout Repository # 저장소를 체크아웃합니다. | |
uses: actions/checkout@v4 | |
- name: Cache Gradle dependencies # Gradle 의존성을 캐시합니다. | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Set up JDK 17 # JDK 17을 설정합니다. | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Gradle 명령 실행을 위한 권한을 부여합니다 | |
run: chmod +x ./gradlew | |
- name: Gradle build를 수행합니다. | |
run: ./gradlew clean build | |
- name: Build docker image and push to docker hub # Docker 이미지를 빌드하고 Docker Hub에 푸시합니다. | |
run: | | |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} . | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} | |
cd: | |
runs-on: ubuntu-latest # ubuntu 최신 버전에서 script를 실행 | |
needs: ci # ci job이 성공적으로 끝나야 cd job이 실행됩니다. | |
# appleboy/ssh-action@master 액션을 사용하여 지정한 서버에 ssh로 접속하고, script를 실행합니다. | |
# script의 내용은 도커의 기존 프로세스들을 제거하고, docker repo로부터 방금 위에서 push한 내용을 pull 받아 실행하는 것입니다. | |
steps: | |
- name: Deploy to server | |
uses: appleboy/ssh-action@master | |
id: deploy | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
port: 22 | |
script: | | |
docker rm -f $(docker ps -qa --filter "name=zzansuni-spring-prod") | |
docker rm -f $(docker ps -qa --filter "name=zzansuni-spring-dev") | |
# 기존에 사용되던 spring 이미지만 제거합니다. | |
docker rmi $(docker images -q --filter "reference=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}") | |
docker image prune -f # 사용하지 않는 도커 이미지들을 제거합니다. | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} | |
docker run -d -p 8080:8080 -e SPRING_PROFILES_ACTIVE=prod \ | |
--name zzansuni-spring-prod \ | |
-e KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }} \ | |
-e NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }} \ | |
-e KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI }} \ | |
-e MYSQL_URL=${{ secrets.MYSQL_URL }} \ | |
-e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} \ | |
-e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} \ | |
-e S3_BUCKET=${{ secrets.S3_BUCKET }} \ | |
-e S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} \ | |
-e S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} \ | |
-e SERVER_URL=https://api.reditus.site \ | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} | |
docker run -d -p 8081:8080 -e SPRING_PROFILES_ACTIVE=dev \ | |
--name zzansuni-spring-dev \ | |
-e KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }} \ | |
-e NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }} \ | |
-e KAKAO_REDIRECT_URI=${{ secrets.KAKAO_DEV_REDIRECT_URI }} \ | |
-e MYSQL_URL=${{ secrets.MYSQL_DEV_URL }} \ | |
-e MYSQL_USERNAME=${{ secrets.MYSQL_USERNAME }} \ | |
-e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} \ | |
-e S3_BUCKET=${{ secrets.S3_BUCKET }} \ | |
-e S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} \ | |
-e S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} \ | |
-e SERVER_URL=http://api.reditus.site:8081 \ | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} |