chore: application.properties 제거 및 application.yml로 로그 설정 이전 #61
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: Build and Deploy ForinK Backend Server | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| workflow_dispatch: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 21 (Corretto) | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'corretto' | |
| - name: Configure AWS Credentials via OIDC | |
| uses: aws-actions/configure-aws-credentials@v3 | |
| with: | |
| role-to-assume: ${{ secrets.IAM_ROLE_ARN }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Cache Gradle packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Create secret application yml | |
| run: | | |
| mkdir -p src/main/resources | |
| echo "${{ secrets.APPLICATION_SECRET_YML }}" > src/main/resources/application-secret.yml | |
| - name: Build project with Gradle | |
| run: ./gradlew clean build -x test | |
| - name: Remove secret application yml after build (security) | |
| run: rm src/main/resources/application-secret.yml | |
| - name: Upload JAR to S3 | |
| run: aws s3 cp build/libs/forink-0.0.1-SNAPSHOT.jar s3://${{ secrets.S3_BUCKET_NAME }}/forink-0.0.1-SNAPSHOT.jar | |
| - name: Deploy to EC2 via AWS SSM | |
| run: | | |
| aws ssm send-command \ | |
| --instance-ids ${{ secrets.EC2_INSTANCE_ID }} \ | |
| --document-name "AWS-RunShellScript" \ | |
| --comment "Deploy Forink Backend" \ | |
| --parameters 'commands=[ | |
| "cd /home/ec2-user/forink-back", | |
| "aws s3 cp s3://${{ secrets.S3_BUCKET_NAME }}/forink-0.0.1-SNAPSHOT.jar .", | |
| "sudo systemctl restart forink-backend" | |
| ]' |