[Fix] Remove Blooming Cache (#145) #99
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: Development Build & Deploy | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| workflow_dispatch: | |
| # permission can be added at job level or workflow level | |
| permissions: | |
| id-token: write # This is required for requesting the JWT | |
| contents: read # This is required for actions/checkout | |
| jobs: | |
| deploy: | |
| name: CD | |
| runs-on: ubuntu-latest | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_IMAGE_NAME: pida-dev | |
| strategy: | |
| matrix: | |
| java-version: [ "21" ] | |
| kotlin-version: [ "2.1.0" ] | |
| distribution: [ "corretto" ] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK ${{ matrix.java-version }} | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: ${{ matrix.java-version }} | |
| kotlin-version: ${{ matrix.kotlin-version }} | |
| distribution: ${{ matrix.distribution }} | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x ./gradlew | |
| - name: Build with Gradle | |
| id: gradle | |
| uses: gradle/gradle-build-action@v3 | |
| with: | |
| arguments: | | |
| :pida-core:core-api:build | |
| --scan | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-region: ap-northeast-2 | |
| role-to-assume: ${{ secrets.OIDC_ROLE_TO_ASSUME }} | |
| role-session-name: pida-server | |
| # Dockerhub 로그인 | |
| - name: Login to Dockerhub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} | |
| # Docker 메타데이터 추출 | |
| - name: Extract Docker metadata | |
| id: metadata | |
| uses: docker/metadata-action@v5.5.0 | |
| env: | |
| DOCKERHUB_IMAGE_FULL_NAME: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }} | |
| with: | |
| images: ${{ env.DOCKERHUB_IMAGE_FULL_NAME }} | |
| tags: | | |
| type=sha,prefix= | |
| # 멀티 아키텍처 지원을 위한 QEMU 설정 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| # 도커 확장 빌드를 위한 Buildx 설정 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Docker 이미지 빌드 및 도커허브로 푸시 | |
| - name: Docker Build and Push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./docker/DockerfileDev | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.metadata.outputs.tags }} | |
| # 서버로 docker-compose 파일 전송 | |
| - name: Copy docker-compose file to EC2 | |
| uses: burnett01/rsync-deployments@7.0.1 | |
| with: | |
| switches: -avzr --delete | |
| remote_host: ${{ secrets.EC2_HOST }} | |
| remote_user: ${{ secrets.EC2_USERNAME }} | |
| remote_key: ${{ secrets.EC2_PRIVATE_KEY }} | |
| path: ./docker/docker-compose.yml | |
| remote_path: /home/ec2-user/app | |
| # EC2로 배포 | |
| - name: Deploy to EC2 Server | |
| uses: appleboy/ssh-action@v1.0.3 | |
| env: | |
| IMAGE_FULL_URL: ${{ steps.metadata.outputs.tags }} | |
| DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }} | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_PRIVATE_KEY }} | |
| envs: IMAGE_FULL_URL, DOCKERHUB_IMAGE_NAME | |
| debug: true | |
| script: | | |
| echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${{ env.DOCKERHUB_USERNAME }}" --password-stdin | |
| cd ~/app | |
| docker compose up -d | |
| docker image prune -a -f |