cookie path /로 수정 및 userDetails NPE 해결 #39
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: [ main ] # dev 브랜치로 푸시할때마다 실행 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 # 저장소 코드 체크아웃 | |
| - name: Set up JDK 21 # Java 개발 킷 설정 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '21' | |
| - name: Make application.yml # application.yml 파일 생성 | |
| run: | | |
| cd ./src/main/resources | |
| echo "${{ secrets.APPLICATION_YML }}" > ./application.yml | |
| shell: bash | |
| - name: Grant execute permission for gradlew # gradlew 실행 권한 부여 | |
| run: chmod +x gradlew | |
| - name: 빌드하기 | |
| run: ./gradlew clean build -x test | |
| # ECR에 접근할 수 있는 권한을 허용받기 위해 | |
| - name: AWS Resource에 접근할 수 있게 AWS credentials 설정 | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-region: ap-northeast-2 | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| - name: ECR에 로그인하기 | |
| id: login-ecr | |
| # 라이브러리가 있음 | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Docker 이미지 생성 | |
| run: docker build -t roomunion-server . | |
| # . 은 현재 경로의 Dockerfile을 기반으로 이미지 파일 생성 | |
| - name: Docker 이미지에 Tag 붙이기 | |
| run: docker tag roomunion-server ${{ steps.login-ecr.outputs.registry }}/roomunion-server:latest | |
| - name: ECR에 Docker 이미지 Push하기 | |
| run: docker push ${{ steps.login-ecr.outputs.registry }}/roomunion-server:latest | |
| outputs: | |
| ecr_registry: ${{ steps.login-ecr.outputs.registry }} | |
| deploy: | |
| needs: build # build 작업이 성공적으로 완료된 후 실행 | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: SSH(원격 접속)로 EC2에 접속하기 | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script_stop: true | |
| script: | | |
| cd roomunion-server | |
| # (ECR이 private이므로)EC2에서 ECR 로그인 – EC2에 AWS CLI + 권한 있어야 함 | |
| aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${{ needs.build.outputs.ecr_registry }} | |
| docker compose down --rmi all | |
| docker pull ${{ needs.build.outputs.ecr_registry }}/roomunion-server:latest | |
| docker compose up -d | |