Skip to content

Commit

Permalink
chore: actions workflow ์ž‘์„ฑ (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
djdongjae authored Apr 8, 2024
1 parent 8d127ed commit 9f21626
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Java CI/CD with Gradle and AWS CodeDeploy

on:
push:
branches:
- main

permissions:
contents: read

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Build with Gradle
run: ./gradlew clean build -x test

- name: Prepare artifacts for deployment
run: |
mkdir -p before-deploy
cp scripts/*.sh before-deploy/
cp appspec.yml before-deploy/
cp build/libs/*.jar before-deploy/
cd before-deploy && zip -r before-deploy *
cd ../ && mkdir -p deploy
mv before-deploy/before-deploy.zip deploy/tasty-inventory.zip
- name: Deploy to S3 (GitHub Artifacts)
uses: actions/upload-artifact@v2
with:
name: deploy
path: deploy

- name: AWS ์ž๊ฒฉ์ฆ๋ช… ์„ค์ •
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2

- name: S3์— ๋ฐฐํฌ
run: aws s3 cp deploy/tasty-inventory.zip s3://tasty-inventory-be-build/tasty-inventory.zip

- name: AWS CodeDeploy๋ฅผ ์‚ฌ์šฉํ•œ ๋ฐฐํฌ
run: |
aws deploy create-deployment \
--application-name Tasty-Inventory-BE \
--deployment-group-name Tasty-Inventory-BE-group \
--s3-location bucket=tasty-inventory-be-build,key=tasty-inventory.zip,bundleType=zip \
--region ap-northeast-2

0 comments on commit 9f21626

Please sign in to comment.