Skip to content

Update main.yml Start MySQL추가 #17

Update main.yml Start MySQL추가

Update main.yml Start MySQL추가 #17

Workflow file for this run

name: Build and Deploy to EC2
# 워크플로우가 언제 실행될 것인지 조건 명시
on:
push:
branches: [ "main"]
pull_request:
branches: [ "main" ]
# AWS 관련 값 변수로 설정
env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: wagu-book-gitget-deploy-bucket
AWS_CODE_DEPLOY_APPLICATION: WAGU-Book-Application-CD
AWS_CODE_DEPLOY_GROUP: WAGU-Book-Deployment-Group
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: make application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION }}" > ./application.yml
- name: Start MySQL
uses: samin/[email protected]
with:
character set server: 'utf8'
mysql database: 'gitget'
mysql user: 'testId1'
mysql password: 'testPw1'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Build and Test
run: ./gradlew build test
- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
- name: AWS credential 설정
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY }}
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip
- name: EC2에 배포
run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip