Merge pull request #233 from team-winey/refactor/#232 #31
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: WINEY-DEV-CD | |
# ํด๋น workflow๊ฐ ์ธ์ ์คํ๋ ๊ฒ์ธ์ง์ ๋ํ ํธ๋ฆฌ๊ฑฐ๋ฅผ ์ง์ | |
on: | |
push: | |
branches: [ dev ] # dev branch๋ก push ๋ ๋ ์คํ๋ฉ๋๋ค. | |
env: | |
S3_BUCKET_NAME: winey-dev | |
jobs: | |
build: | |
name: Code deployment | |
# ์คํ ํ๊ฒฝ | |
runs-on: ubuntu-latest | |
steps: | |
# 1) ์ํฌํ๋ก์ฐ ์คํ ์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฒดํฌ์์ ํ์ | |
- name: checkout | |
uses: actions/checkout@v3 | |
# 2) JDK 11๋ฒ์ ์ค์น, ๋ค๋ฅธ JDK ๋ฒ์ ์ ์ฌ์ฉํ๋ค๋ฉด ์์ | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
# 3) ํ๊ฒฝ๋ณ์ ํ์ผ ์์ฑ | |
- name: make application.properties ํ์ผ ์์ฑ | |
run: | | |
## create application.yml | |
mkdir -p ./src/main/resources | |
# application.yml ํ์ผ ์์ฑ | |
touch ./application.yml | |
# GitHub-Actions ์์ ์ค์ ํ ๊ฐ์ application.yml ํ์ผ์ ์ฐ๊ธฐ | |
echo "${{ secrets.WINEY_DEV_APPLICATION }}" >> ./application.yaml | |
# winey-firebase.json ํ์ผ ์์ฑ | |
touch ./winey-firebase.json | |
# Firebase secrets ํ์ผ ๋ณต์ฌ | |
echo "${{ secrets.WINEY_FIREBASE }}" >> ./winey-firebase.json | |
# application.yml ํ์ผ ํ์ธ | |
cat ./application.yml | |
shell: bash | |
# ์ด ์ํฌํ๋ก์ฐ๋ gradle build | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle # ์ค์ application build ํ ์คํธ ์ ์ธ | |
run: ./gradlew build -x test | |
# ๋๋ ํ ๋ฆฌ ์์ฑ | |
- name: Make Directory | |
run: mkdir -p deploy | |
# Jar ํ์ผ ๋ณต์ฌ | |
- name: Copy Jar | |
run: cp ./build/libs/*.jar ./deploy | |
# appspec.yml ํ์ผ ๋ณต์ฌ | |
- name: Copy appspec.yml | |
run: cp appspec.yml ./deploy | |
# script files ๋ณต์ฌ | |
- name: Copy script | |
run: cp ./scripts/*.sh ./deploy | |
- name: Make zip file | |
run: zip -r ./winey_dev_server.zip ./deploy | |
shell: bash | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_DEV_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_DEV_SECRET_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./winey_dev_server.zip s3://$S3_BUCKET_NAME/ | |
# Deploy | |
- name: Deploy | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_DEV_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_DEV_SECRET_KEY }} | |
run: | |
aws deploy create-deployment | |
--application-name winey-dev-codedeploy | |
--deployment-group-name winey-dev-codedeploy-group | |
--file-exists-behavior OVERWRITE | |
--s3-location bucket=winey-dev,bundleType=zip,key=winey_dev_server.zip | |
--region ap-northeast-2 |