Skip to content

Commit

Permalink
docs: main 브랜치 CI/CD 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-junho committed Oct 21, 2023
1 parent bb9dd1c commit 4601ae3
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/mainCodeDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Execute CD

on:
push:
branches: [ "main" ]

permissions:
contents: read

env:
BUCKET_NAME: space-club-be-bucket
DIRECTORY_NAME: space-club-be-directory
CODE_DEPLOY_APP_NAME: space-club-be-deploy
DEPLOYMENT_GROUP_NAME: space-club-be-deploy-group

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Check Repo code With Submodules
uses: actions/checkout@v3
with:
submodules: 'true'
token: ${{secrets.GH_ACCESS_TOKEN}}

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Gradle Build Action
uses: gradle/[email protected]
with:
arguments: build

- name: Make Zip File
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.PRIVATE_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$DIRECTORY_NAME/$GITHUB_SHA.zip

- name: Deploy to EC2 Instance
run: aws deploy create-deployment --application-name $CODE_DEPLOY_APP_NAME --deployment-group-name $DEPLOYMENT_GROUP_NAME --deployment-config-name CodeDeployDefault.OneAtATime --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$DIRECTORY_NAME/$GITHUB_SHA.zip

0 comments on commit 4601ae3

Please sign in to comment.