[docs] README 수정 #173
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: Docker Build and Push | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 코드 불러오기 | |
uses: actions/checkout@v3 | |
- name: JDK 세팅 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
working-directory: ./ | |
- name: MySQL 셋업 # 서버 test 코드 에러 | |
uses: samin/mysql-action@v1 | |
with: | |
character set server: 'utf8' | |
mysql database: 'booktalk' | |
mysql user: 'root' | |
mysql password: 'booktalk1234' | |
- name: gradlew 실행 권한 부여 | |
run: chmod +x gradlew | |
working-directory: ./ | |
- name: 프로젝트 빌드 | |
run: | | |
DB_URL=${{ secrets.GLOBAL_DB_URL }} \ | |
DB_USERNAME=${{ secrets.GLOBAL_DB_USERNAME }} \ | |
DB_PASSWORD=${{ secrets.GLOBAL_DB_PASSWORD }} \ | |
SERVER_URL=${{ secrets.SERVER_URL }} \ | |
RESTAPI_KEY=${{ secrets.RESTAPI_KEY }} \ | |
JWT_SECRET=${{ secrets.JWT_SECRET }} \ | |
ACCESS_TOKEN_EXPIRE_TIME=${{ secrets.ACCESS_TOKEN_EXPIRE_TIME }} \ | |
REFRESH_TOKEN_EXPIRE_TIME=${{ secrets.REFRESH_TOKEN_EXPIRE_TIME }} \ | |
REDIS_HOST=${{ secrets.REDIS_HOST }} \ | |
AWS_S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }} \ | |
AWS_S3_BUCKET_ACCESS_KEY=${{ secrets.AWS_S3_BUCKET_ACCESS_KEY }} \ | |
AWS_S3_BUCKET_SECRET_KEY=${{ secrets.AWS_S3_BUCKET_SECRET_KEY }} \ | |
IS_LOCAL=${{ secrets.IS_LOCAL }} \ | |
./gradlew build | |
working-directory: ./ | |
- name: jar 파일을 github aciton 에 업로드 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: spring-app-artifacts | |
path: build/libs/*.jar | |
- name: docker 셋업 | |
uses: docker/setup-buildx-action@v1 | |
- name: docker 로그인 | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: docker image build & hub에 업로드 | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/booktalk-spring:latest | |
- name: Portainer spring-container 재가동 요청 | |
run: | | |
curl -X POST ${{ secrets.PORTAINER_WEBHOOK_LINK }} | |
- name: build 캐시 삭제 (이후 cicd 시에 꼬이지 않도록) | |
run: ./gradlew clean | |
working-directory: ./ |