๐ docs: README ์์ #88
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: MODY service Dev Build and Deploy to AWS | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. ์ฝ๋ ์ฒดํฌ์์ | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
# 1-1. Java 21 ์ธํ | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
# 1-2. application.yml ํ์ผ ์์ฑ | |
- name: make application.yml | |
run: | | |
# create application.yml | |
cd ./src/main | |
cd ./resources | |
# application.yml ํ์ผ ์์ฑํ๊ธฐ | |
touch ./application.yml | |
# Secrets์ ์ ์ฅํ ๊ฐ์ application.yml ํ์ผ์ ์ฐ๊ธฐ | |
echo "${{ secrets.DEV_YML }}" >> ./application.yml | |
shell: bash # ์คํฌ๋ฆฝํธ๊ฐ Bash ์ ธ์์ ์คํ | |
# 1-2-1 start.sh ํ์ผ ์์ฑ | |
- name: make start.sh | |
run: | | |
# create start.sh | |
cd ./scripts | |
# start.sh ํ์ผ ์์ฑํ๊ธฐ | |
touch ./start.sh | |
# Secrets์ ์ ์ฅํ ๊ฐ์ start.sh ํ์ผ์ ์ฐ๊ธฐ | |
echo "${{ secrets.START_SH }}" >> ./start.sh | |
# 1-3. Spring Boot ์ ํ๋ฆฌ์ผ์ด์ ๋น๋ | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
# 2. AWS CLI ์ค์ | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
# 3. Docker ๋ก๊ทธ์ธ | |
- name: Log in to Amazon ECR | |
run: | | |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ECR_REPO }} | |
# 4. Docker ์ด๋ฏธ์ง ๋น๋ | |
- name: Build Docker Image | |
run: | | |
docker build -t ${{ secrets.AWS_ECR_REPO }}:latest . | |
docker tag ${{ secrets.AWS_ECR_REPO }}:latest ${{ secrets.AWS_ECR_REPO }}:latest | |
# 5. Docker ์ด๋ฏธ์ง ํธ์ | |
- name: Push to Amazon ECR | |
run: | | |
docker push ${{ secrets.AWS_ECR_REPO }}:latest | |
# 6-0. S3 ์ ๋ก๋ | |
- name: Upload to S3 | |
run: | | |
zip -r deploy.zip appspec.yml scripts/ | |
aws s3 cp deploy.zip s3://modi-service-bucket/deploy/deploy.zip | |
# 6. CodeDeploy ํธ๋ฆฌ๊ฑฐ | |
- name: Trigger CodeDeploy Deployment | |
run: | | |
aws deploy create-deployment \ | |
--application-name modi-server \ | |
--deployment-group-name modi-server-group \ | |
--revision "{\"revisionType\":\"S3\",\"s3Location\":{\"bucket\":\"modi-service-bucket\",\"key\":\"deploy/deploy.zip\",\"bundleType\":\"zip\"}}" |