Skip to content

Update README.md

Update README.md #124

Workflow file for this run

# 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: CICD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: dagather20-deploy-bucket
AWS_CODE_DEPLOY_APPLICATION: dagather-codedeploy
AWS_CODE_DEPLOY_GROUP: dagather-codedeploy-group
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*',
'**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: make main application.yml
run: |
sudo mkdir -p ./src/main/resources
sudo chmod 777 ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.MAIN_YML }}" > ./application.yml
# 파일 없으면 빌드 에러
- uses: actions/upload-artifact@v3
with:
name: application.yml
path: ./src/main/resources/application.yml
if-no-files-found: 'error'
- name: Build with Gradle
run: ./gradlew clean build -x test
shell: bash
- name: AWS credential 설정
if: contains(github.ref, 'main')
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 AWS S3
if: contains(github.ref, 'main')
run: |
aws deploy push \
--application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} \
--ignore-hidden-files \
--s3-location s3://$AWS_S3_BUCKET/build/$GITHUB_SHA.zip \
--source .
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
- name: Deploy to AWS EC2 from S3
if: contains(github.ref, 'main')
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=build/$GITHUB_SHA.zip,bundleType=zip