⚡ MarkSphere v1.0.10 #40
This file contains hidden or 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
| # github repository actions 페이지에 나타날 이름 | |
| name: CI/CD using Github Actions & AWS CodeDeploy | |
| # event trigger | |
| # main 브랜치에 push가 되었을 때 실행 | |
| on: | |
| push: | |
| branches: [ "main", "test" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # JDK setting - github actions에서 사용할 JDK 설정 | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| # gradle caching - 빌드 시간 향상 | |
| - 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- | |
| # gradle build | |
| - name: Build with Gradle | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew build -x test | |
| # make zip file | |
| - name: Make zip file | |
| run: zip -qq -r ./$GITHUB_SHA.zip . | |
| shell: bash | |
| # AWS 사용자 정보 입력 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.ACCESS_KEY_SECRET }} | |
| aws-region: ap-northeast-2 | |
| # S3에 zip 파일 업로드 | |
| - name: Upload to S3 | |
| run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME }}/deploy/$GITHUB_SHA.zip --source . | |
| # CodeDeploy에 배포 요청 | |
| - name: Code Deploy | |
| run: aws deploy create-deployment --application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} | |
| --deployment-config-name CodeDeployDefault.OneAtATime | |
| --deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} | |
| --s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=deploy/$GITHUB_SHA.zip |