๐Fix Rollback2 #74
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ "develop" ] # ๋์ค์ main์ผ๋ก ๋ณ๊ฒฝ ๊ฐ๋ฅ | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Make gradlew executable | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew clean build -x test | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-jar | |
| path: build/libs/*.jar | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: app-jar | |
| path: . | |
| - name: Copy JAR to EC2 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| source: "*.jar" | |
| target: "/home/ubuntu/back-end/" | |
| - name: Deploy to EC2 | |
| uses: appleboy/ssh-action@v1.0.0 | |
| # env: | |
| # APPLICATION_YML: ${{ secrets.APPLICATION_YML }} | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| # Base64๋ก ์ ๋ฌ๋ yml ๋์ฝ๋ฉ | |
| echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > /home/ubuntu/back-end/application.yml | |
| # ๋ฐฐํฌ ์คํฌ๋ฆฝํธ ์คํ | |
| bash ~/back-end/deploy.sh | |
| - name: Restart Spring Boot service | |
| uses: appleboy/ssh-action@v1.0.0 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| script: | | |
| sudo systemctl daemon-reload | |
| sudo systemctl restart mathfusion | |
| sudo systemctl status mathfusion |