Skip to content

Merge pull request #239 from team-winey/feature/#238 #34

Merge pull request #239 from team-winey/feature/#238

Merge pull request #239 from team-winey/feature/#238 #34

Workflow file for this run

# ์›Œํฌํ”Œ๋กœ์šฐ์˜ ์ด๋ฆ„ ์ง€์ •
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