From 111f7a95d65371a43171fbdec1ff4914317b7781 Mon Sep 17 00:00:00 2001 From: Kang Duoh <143769463+kduoh99@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:38:53 +0900 Subject: [PATCH] Create gradle.yml --- .github/workflows/gradle.yml | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..9237380 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -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/momento.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/momento.zip s3://momento-build/momento.zip + + - name: AWS CodeDeploy를 사용한 배포 + run: | + aws deploy create-deployment \ + --application-name momento-deploy \ + --deployment-group-name momento-deploy-group \ + --s3-location bucket=momento-build,key=momento.zip,bundleType=zip \ + --region ap-northeast-2