[HIMIN-209] test: 배달 서비스 테스트 추가 #11
Workflow file for this run
This file contains 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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: Java CI with Gradle | |
on: | |
pull_request: | |
branches: [ "main" ] | |
env: | |
PROJECT_NAME: himin | |
BUCKET_NAME: himin-ci-cd-bucket | |
CODE_DEPLOY_APP_NAME: himin-cicd | |
DEPLOYMENT_GROUP_NAME: himin-instance-group | |
permissions: | |
contents: read | |
jobs: | |
build: | |
## CI | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Make application.properties | |
run: | | |
cd ./src/main/resources | |
touch ./application.yml | |
echo "${{ secrets.DATABASE_PROPERTIES }}" >> ./application.yml | |
shell: bash | |
- name: Setup MySQL | |
uses: samin/mysql-action@v1.3 | |
with: | |
host port: 3306 | |
container port: 3306 | |
mysql database: 'himin' | |
mysql user: 'test' | |
mysql password: ${{ secrets.MYSQL_PASSWORD }} | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Test with Gradle | |
run: ./gradlew test | |
- name: Build with Gradle | |
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 | |
with: | |
arguments: build | |
## CD | |
- name: Make Zip File | |
run: zip -qq -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip | |
- name: Code Deploy To EC2 instance | |
run: aws deploy create-deployment | |
--application-name $CODE_DEPLOY_APP_NAME | |
--deployment-config-name CodeDeployDefault.AllAtOnce | |
--deployment-group-name $DEPLOYMENT_GROUP_NAME | |
--s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip |