Skip to content

Commit

Permalink
deploy - #145 ci cd 플로우 dev와 prod로 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
kseysh committed May 28, 2024
1 parent 402242d commit 7a8dd0b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🚀 APPLICATION-DEPLOY!
name: 🎉DEV-SERVER-DEPLOY🎉

on:
push:
Expand All @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
codedeploy-application-name: [ hmh-codedeploy-app ]
deployment-group-name: [ hmh-app-deploy-group ]
deployment-group-name: [ hmh-dev-deploy-group ]
s3-bucket: [ hmh-server-bucket ]

steps:
Expand All @@ -30,7 +30,7 @@ jobs:
shell: bash

- name: copy yml file
run: echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml
run: echo "${{ secrets.APPLICATION_DEV_YML }}" > ./src/main/resources/application.yml

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -49,12 +49,12 @@ jobs:
aws-region: ${{ secrets.AWS_REGION }}

- name: 🚀 s3 upload
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/deploy/$GITHUB_SHA.zip
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/dev/deploy/$GITHUB_SHA.zip

- name: ☀️ CodeDeploy~!
run: aws deploy create-deployment
--application-name ${{matrix.codedeploy-application-name}}
--deployment-group-name ${{matrix.deployment-group-name}}
--s3-location bucket=${{matrix.s3-bucket}},bundleType=zip,key=deploy/$GITHUB_SHA.zip
--s3-location bucket=${{matrix.s3-bucket}},bundleType=zip,key=dev/deploy/$GITHUB_SHA.zip
--file-exists-behavior OVERWRITE
--region ap-northeast-2
60 changes: 60 additions & 0 deletions .github/workflows/hmh-cd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 🎉PROD-SERVER-DEPLOY🎉

on:
push:
branches: [ 'main' ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
codedeploy-application-name: [ hmh-codedeploy-app ]
deployment-group-name: [ hmh-prod-deploy-group ]
s3-bucket: [ hmh-server-bucket ]

steps:
- name: checkout
uses: actions/checkout@v3

- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'

- name: mkdir resources folder
run: |
mkdir ./src/main/resources
touch ./src/main/resources/application.yml
shell: bash

- name: copy yml file
run: echo "${{ secrets.APPLICATION_PROD_YML }}" > ./src/main/resources/application.yml

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: 🐈 Gradle Build
run: ./gradlew clean build

- name: 📂 Make zip file
run: zip -r ./$GITHUB_SHA.zip .

- name: 🪣 S3 upload
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: 🚀 s3 upload
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/prod/deploy/$GITHUB_SHA.zip # 수정 고려

- name: ☀️ CodeDeploy~!
run: aws deploy create-deployment
--application-name ${{matrix.codedeploy-application-name}}
--deployment-group-name ${{matrix.deployment-group-name}}
--s3-location bucket=${{matrix.s3-bucket}},bundleType=zip,key=prod/deploy/$GITHUB_SHA.zip
--file-exists-behavior OVERWRITE
--region ap-northeast-2
8 changes: 4 additions & 4 deletions .github/workflows/hmh-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: 🏭 APPLICATION-BUILD!
on:
pull_request:
branches: [ "develop" ]
#push:
#branches: [ "develop" ]
push:
branches: [ "develop" ]

permissions:
contents: read
Expand All @@ -28,7 +28,7 @@ jobs:
mkdir ./src/main/resources
touch ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_YML }}" >> ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_DEV_YML }}" >> ./src/main/resources/application.yml
cat ./src/main/resources/application.yml
shell: bash
Expand All @@ -39,4 +39,4 @@ jobs:
- name: Build with Gradle
run: |
./gradlew build -x test
./gradlew clean build

0 comments on commit 7a8dd0b

Please sign in to comment.