GSM-Networking Main CD #34
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: GSM-Networking Main CD | |
on: | |
# # feature/CI-CD 브랜치에 푸쉬될 경우 실행하는 트리거 | |
# push: | |
# branches: [ "feature/CICD-enviroment-divide" ] | |
# Develop 브랜치에 머지된 코드의 CI가 실행완료 되었을때 실행하는 트리거 | |
workflow_run: | |
workflows: [ "GSM-Networking On Main Merge CI" ] | |
types: | |
- completed | |
# 수동으로 실행하기 위한 트리거 | |
workflow_dispatch: | |
jobs: | |
CD: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Setup Gradle's permission | |
run: chmod +x gradlew | |
- name: Make YML file | |
run: | | |
rm -rf ./src/main/resources/application-prod.yml | |
touch ./src/main/resources/application-prod.yml | |
echo "${{ secrets.PROD_YML_FILE }}" > ./src/main/resources/application-prod.yml | |
- name: Run build with Gradle wrapper | |
run: ./gradlew clean build | |
- 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: ${{ secrets.AWS_REGION }} | |
- name: Make zip file | |
run: zip -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- name: Upload to S3 | |
run: aws s3 cp --region ${{ secrets.AWS_REGION }} ./$GITHUB_SHA.zip s3://${{ secrets.BUCKET_NAME }}/prod/$GITHUB_SHA.zip | |
- name: Code Deploy | |
run: aws deploy create-deployment --application-name gsm-networking-codedeploy --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name gsm-networking-prod --s3-location bucket=${{ secrets.BUCKET_NAME }},bundleType=zip,key=prod/$GITHUB_SHA.zip |