Update README.md #43
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: together-server CI/CD | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. GitHub Repository Code Checkout | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| # 2. JDK install | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v2 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| # 3. Spring Boot Project Build | |
| - name: Build Spring Boot project | |
| run: | | |
| cd backend | |
| ./gradlew clean build -x test | |
| # 4 EC2λ‘ jar μ λ‘λ | |
| - name: Upload Jar to EC2 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| source: | | |
| backend/build/libs/backend-0.0.1-SNAPSHOT.jar | |
| target: ~/deploy/ | |
| strip_components: 3 | |
| # 5. EC2λ‘ run.sh μ λ‘λ | |
| - name: Upload run.sh to EC2 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| source: | | |
| backend/run.sh | |
| target: ~/deploy/ | |
| strip_components: 1 | |
| # 7. EC2μμ run.sh μ€ν | |
| - name: Run remote script | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| cd ~/deploy | |
| chmod +x run.sh | |
| ./run.sh | |