게시글 수정, 삭제 기능 구현 (#7) #13
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 Deploy on Merge to develop | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - develop | |
| - main | |
| paths: | |
| - 'BACK/spring-app/**' | |
| jobs: | |
| deploy: | |
| name: Deploy to EC2 | |
| if: github.event.pull_request.merged == true # PR이 머지된 경우만 실행 | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: deploy-spring | |
| cancel-in-progress: true # 이전 실행 중인 워크플로를 취소 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create application properties files | |
| run: | | |
| mkdir -p BACK/spring-app/src/main/resources | |
| echo "${{ secrets.APPLICATION_PROPERTIES_FOR_TEST }}" > BACK/spring-app/src/main/resources/application-test.properties | |
| echo "${{ secrets.APPLICATION_PROPERTIES_FOR_PROD }}" > BACK/spring-app/src/main/resources/application-prod.properties | |
| - name: Set up SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -H "${{ vars.EC2_HOST }}" >> ~/.ssh/known_hosts | |
| - name: Transfer properties files to EC2 | |
| run: | | |
| scp BACK/spring-app/src/main/resources/application-test.properties ec2-user@${{ vars.EC2_HOST }}:/home/ec2-user/starchive/BACK/spring-app/src/main/resources/ | |
| scp BACK/spring-app/src/main/resources/application-prod.properties ec2-user@${{ vars.EC2_HOST }}:/home/ec2-user/starchive/BACK/spring-app/src/main/resources/ | |
| - name: Execute Deployment Script on EC2 | |
| run: | | |
| ssh ec2-user@${{ vars.EC2_HOST }} << 'EOF' | |
| cd /home/ec2-user/starchive/scripts | |
| git checkout develop | |
| # 스프링 배포 스크립트 실행 | |
| ./spring-deploy.sh | |
| EOF |