[feat] Elastic Search를 사용한 지도 검색 기능 구현 #12
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 - Dev | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - develop | |
| jobs: | |
| build: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| outputs: | |
| docker_image_tag: ${{ steps.set_tag.outputs.docker_image_tag }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Make secret files | |
| run: | | |
| mkdir -p ./src/main/resources | |
| echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml | |
| - name: Build with Gradle | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean build | |
| - name: Set Docker image tag (by date) | |
| id: set_tag | |
| run: echo "docker_image_tag=$(date +'%Y%m%d-%H%M')" >> $GITHUB_OUTPUT | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Build and Push Docker image | |
| run: | | |
| docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/wayble:${{ steps.set_tag.outputs.docker_image_tag }} . | |
| docker push ${{ secrets.DOCKER_HUB_USERNAME }}/wayble:${{ steps.set_tag.outputs.docker_image_tag }} | |
| deploy: | |
| name: Deploy to EC2 | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: SSH to EC2 and deploy | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| cd wayble-spring | |
| git pull | |
| echo "TAG=${{ needs.build.outputs.docker_image_tag }}" > .env | |
| sudo docker-compose stop wayble-app | |
| sudo docker-compose rm -f wayble-app | |
| sudo docker rmi ${{ secrets.DOCKER_HUB_USERNAME }}/wayble:$TAG || true | |
| sudo docker-compose pull wayble-app | |
| sudo docker-compose up -d wayble-app --no-deps | |
| # name: CD - DEVELOP | |
| # on: #이 워크플로우가 언제 실행될지 트리거를 정의함. | |
| # pull_request: | |
| # types : [closed] #누군가가 Pull request를 닫았을 때 실행됨. | |
| # workflow_dispatch: #수동 실행도 가능하도록 | |
| # jobs: #실제 실행할 작업을 정의 | |
| # build: #작업 이름 | |
| # runs-on: ubuntu-latest #OS환경 | |
| # if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' | |
| # #닫힌 Pull Request 중에서, 병합된 것이고, 병합 대상 브랜치가 develop 브랜치일 경우에만 이 작업을 실행 |