Running #44
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: CICD | |
run-name: Running | |
on: | |
push: | |
branches: | |
- develop # develop์ด๋ผ๋ ๋ธ๋ฐ์น๋ก ํธ์ฌํ์ ๋ ์คํ | |
- 'releases/**' | |
env: | |
AWS_REGION: ap-northeast-2 | |
AWS_S3_BUCKET: app-release-files | |
AWS_CODE_BUCKET_NAME : s3-cicd-bucket # ๊ธฐ์ตํด๋๋ผ๊ณ ํ๋ ๋ฒํท ์ด๋ฆ | |
AWS_CODE_DEPLOY_APPLICATION: cd-application-cicd # ๊ธฐ์ตํด๋๋ผ๊ณ ํ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด๋ฆ | |
AWS_CODE_DEPLOY_GROUP: cd-publish-cicd # ๊ธฐ์ตํด๋๋ผ๊ณ ํ๋ ๋ฐฐํฌ ๊ทธ๋ฃน ์ด๋ฆ | |
jobs: | |
build-with-gradle: | |
runs-on: ubuntu-20.04 # ubuntu ver | |
steps: | |
- name: develop ๋ธ๋์น๋ก ์ด๋ | |
uses: actions/checkout@v3 | |
with: | |
ref: develop | |
- name: JDK 17 ์ค์น | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: Create application.yml | |
run: | | |
mkdir -p src/main/resources | |
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml | |
# - name: create firebase key | |
# run: | | |
# cd ./src/main/resources | |
# ls -a . | |
# touch ./bangfer-firebase-key.json | |
# echo "${{ secrets.FIREBASE_KEY }}" > ./bangfer-firebase-key.json | |
# shell: bash | |
- name: create-json | |
id: create-json | |
uses: jsdaniell/[email protected] | |
with: | |
name: "bangfer-firebase-key.json" | |
json: ${{ secrets.FIREBASE_KEY }} | |
dir: 'src/main/resources/' | |
- name: gradlew์ ์คํ ๊ถํ ๋ถ์ฌ | |
run: chmod +x ./gradlew | |
- name: ํ๋ก์ ํธ ๋น๋ | |
run: ./gradlew clean build -x test | |
- name: AWS credential ์ค์ | |
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: Make zip file | |
run: zip -qq -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ env.AWS_CODE_BUCKET_NAME }}/cicdDir/$GITHUB_SHA.zip | |
# - name: S3์ ์ ๋ก๋ | |
# run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://${{ env.AWS_CODE_BUCKET_NAME }}/cicdDir/$GITHUB_SHA.zip --source . | |
- name: EC2์ ๋ฐฐํฌ | |
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=${{ env.AWS_CODE_BUCKET_NAME }},key=cicdDir/$GITHUB_SHA.zip,bundleType=zip |