Merge pull request #32 from jeondain/feat/#31 #16
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: Spring Boot CI/CD | |
| on: | |
| push: | |
| branches: [ develop ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v3 | |
| - name: Set up application.yml | |
| run: | | |
| echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew clean build -x test | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to DockerHub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| run: | | |
| docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/leaf-map . | |
| docker push ${{ secrets.DOCKERHUB_USERNAME }}/leaf-map | |
| - name: Deploy to EC2 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/leaf-map | |
| docker stop leaf-map || true | |
| docker rm leaf-map || true | |
| docker run -d --name leaf-map -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/leaf-map |