Merge pull request #122 from IDEA-CAMPUS/develop #49
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
name: Deploy to Amazon EC2 | |
on: | |
push: | |
branches: | |
- release | |
env: | |
AWS_REGION: ap-northeast-2 | |
S3_BUCKET_NAME: ideac-github-actions-s3-bucket | |
CODE_DEPLOY_APPLICATION_NAME: ideac-codedeploy-app | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: ideac-codedeploy-deployment-group | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME2: ideac-admin-codedeploy-deployment-group | |
jobs: | |
deploy_core_admin: | |
name: Deploy Core and Admin modules | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Set IDEAC-CORE YML | |
run: | | |
mkdir -p ideac-core/src/main/resources | |
echo "${{ secrets.APPLICATION_MAIL_YML }}" | base64 --decode > ideac-core/src/main/resources/application-mail.yml | |
mkdir -p ideac-core/src/main/resources/oauth2 | |
echo "${{ secrets.APPLICATION_OAUTH2_YML }}" | base64 --decode > ideac-core/src/main/resources/oauth2/application-oauth2.yml | |
- name: Set IDEAC-ADMIN YML | |
run: | | |
mkdir -p ideac-admin/src/main/resources | |
echo "${{ secrets.ADMIN_APPLICATION_YML }}" | base64 --decode > ideac-admin/src/main/resources/application.yml | |
echo "${{ secrets.ADMIN_APPLICATION_SWAGGER_YML }}" | base64 --decode > ideac-admin/src/main/resources/application-swagger.yml | |
- name: Build Core and Admin modules with Gradle | |
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee | |
with: | |
arguments: clean build -x test | |
- 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: ${{ env.AWS_REGION }} | |
- name: Upload Core and Admin modules to AWS S3 | |
run: | | |
cp -r ideac-admin/appspec.yml . | |
cp -r ideac-admin/scripts . | |
# ideac-core와 ideac-admin 모듈을 함께 압축하여 업로드할 파일을 생성합니다. | |
zip -r $GITHUB_SHA-core-admin.zip ideac-core ideac-admin appspec.yml scripts | |
# 생성한 파일을 S3로 업로드합니다. | |
aws s3 cp $GITHUB_SHA-core-admin.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA-core-admin.zip | |
- name: Deploy Core and Admin modules to AWS EC2 from S3 | |
run: | | |
aws deploy create-deployment \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME2 }} \ | |
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA-core-admin.zip,bundleType=zip | |
deploy_core_user: | |
name: Deploy Core and User modules | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Set IDEAC-CORE YML | |
run: | | |
mkdir -p ideac-core/src/main/resources | |
echo "${{ secrets.APPLICATION_MAIL_YML }}" | base64 --decode > ideac-core/src/main/resources/application-mail.yml | |
mkdir -p ideac-core/src/main/resources/oauth2 | |
echo "${{ secrets.APPLICATION_OAUTH2_YML }}" | base64 --decode > ideac-core/src/main/resources/oauth2/application-oauth2.yml | |
- name: Set IDEAC-USER YML | |
run: | | |
mkdir -p ideac-user/src/main/resources | |
echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > ideac-user/src/main/resources/application.yml | |
echo "${{ secrets.APPLICATION_SWAGGER_YML }}" | base64 --decode > ideac-user/src/main/resources/application-swagger.yml | |
- name: Build Core and User modules with Gradle | |
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee | |
with: | |
arguments: clean build -x test | |
- 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: ${{ env.AWS_REGION }} | |
- name: Upload Core and User modules to AWS S3 | |
run: | | |
cp -r ideac-user/appspec.yml . | |
cp -r ideac-user/scripts . | |
# ideac-core와 ideac-user 모듈을 함께 압축하여 업로드할 파일을 생성합니다. | |
zip -r $GITHUB_SHA-core-user.zip ideac-core ideac-user appspec.yml scripts | |
# 생성한 파일을 S3로 업로드합니다. | |
aws s3 cp $GITHUB_SHA-core-user.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA-core-user.zip | |
- name: Deploy Core and User modules to AWS EC2 from S3 | |
run: | | |
aws deploy create-deployment \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ | |
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA-core-user.zip,bundleType=zip |