feat: 스프린트 수정 #50
This file contains hidden or 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: CD | |
| on: | |
| push: | |
| branches: [ "develop" ] | |
| jobs: | |
| deploy-ci: | |
| runs-on: ubuntu-22.04 | |
| env: | |
| working-directory: . | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'corretto' | |
| java-version: '21' | |
| - name: application.yaml 생성 | |
| run: | | |
| cd src/main/resources | |
| touch ./application-secret.yml | |
| echo "${{ secrets.CI_APPLICATION_SECRET }}" > ./application-secret.yml | |
| working-directory: ${{ env.working-directory }} | |
| - name: cloud-task-key.json 생성 | |
| run: | | |
| cd src/main/resources | |
| touch ./cloud-task-key.json | |
| echo "${{ secrets.CLOUD_TASK_KEY_JSON_BASE64 }}" | base64 -d > cloud-task-key.json | |
| working-directory: ${{ env.working-directory }} | |
| - name: 빌드 | |
| run: | | |
| chmod +x gradlew | |
| ./gradlew build -x test | |
| working-directory: ${{ env.working-directory }} | |
| shell: bash | |
| - name: docker build 환경 설정 | |
| uses: docker/[email protected] | |
| - name: docker hub 로그인 | |
| uses: docker/[email protected] | |
| with: | |
| username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN }} | |
| - name: docker image 빌드 및 푸시 | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_LOGIN_USERNAME }}/dev:latest | |
| deploy-cd: | |
| needs: deploy-ci | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: docker 컨테이너 실행 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SERVER_IP }} | |
| username: ${{ secrets.SERVER_USER }} | |
| key: ${{ secrets.SERVER_KEY }} | |
| script: | | |
| cd ~ | |
| ./deploy.sh |