fix conflicts #127
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: | |
push: | |
branches: [ "main", "feature/*" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
write-all | |
env: | |
CLOUDFRONT_DOMAIN: ${{secrets.CLOUDFRONT_DOMAIN}} | |
DATASOURCE_PASSWORD_DEV: ${{secrets.DATASOURCE_PASSWORD_DEV}} | |
DATASOURCE_URL_DEV: ${{secrets.DATASOURCE_URL_DEV}} | |
DATASOURCE_USERNAME_DEV: ${{secrets.DATASOURCE_USERNAME_DEV}} | |
S3_SECRET_KEY: ${{secrets.S3_SECRET_KEY}} | |
S3_ACCESS_KEY: ${{secrets.S3_ACCESS_KEY}} | |
JWT_SECRET_KEY: ${{secrets.JWT_SECRET_KEY}} | |
JWT_EXPIRED_IN: ${{secrets.JWT_EXPIRED_IN}} | |
PROJECT_NAME: couphone_project | |
BUCKET_NAME: couphone-bucket | |
CODE_DEPLOY_APP_NAME: couphone | |
DEPLOYMENT_GROUP_NAME: couphone_instance | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' | |
java-version: 17 | |
- name: Setup MySQL | |
uses: mirromutth/[email protected] | |
with: | |
host port: 3306 | |
container port: 3306 | |
mysql database: 'couphone-database' | |
mysql user: ${{secrets.DATASOURCE_USERNAME_DEV}} | |
mysql password: ${{secrets.DATASOURCE_PASSWORD_DEV}} | |
- name: Permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash | |
- name: Build and Test | |
run: ./gradlew build test | |
# --------------------------추가 | |
- 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_SECRET_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 | |
# --------------------------추가 |