Merge pull request #22 from eunxeum/main #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI/CD with Gradle and AWS CodeDeploy | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
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/goody.zip | |
- name: Deploy to S3 (GitHub Artifacts) | |
uses: actions/upload-artifact@v3 | |
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/goody.zip s3://goody-build/goody.zip | |
- name: AWS CodeDeploy๋ฅผ ์ฌ์ฉํ ๋ฐฐํฌ | |
run: | | |
aws deploy create-deployment \ | |
--application-name goody-deploy \ | |
--deployment-group-name goody-deploy-group \ | |
--s3-location bucket=goody-build,key=goody.zip,bundleType=zip \ | |
--region ap-northeast-2 |