-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from Kumoh-talk/main
테스트서버 cicd 파이프라인 적용
- Loading branch information
Showing
339 changed files
with
14,071 additions
and
2,673 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Java CI with Gradle and Deploy to Amazon ECS | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: checkout action with submodule | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.ACTION_TOKEN }} | ||
submodules: true | ||
|
||
- name: Set up JDK 17 action | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle action | ||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | ||
|
||
- name: add +x permission to gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew clean build | ||
|
||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-libs | ||
path: build/libs/*.jar | ||
|
||
deploy: | ||
needs: build | ||
if: github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout action | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Download Build Artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build-libs | ||
path: build/libs | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -t $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG . | ||
docker push $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition ${{ secrets.ECS_TASK_DEFINITION }} --query taskDefinition > task-definition.json | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: task-definition.json | ||
container-name: ${{ secrets.CONTAINER_NAME }} | ||
image: ${{ steps.build-image.outputs.image }} | ||
environment: | | ||
USE_PROFILE=prod | ||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: ${{ secrets.ECS_SERVICE }} | ||
cluster: ${{ secrets.ECS_CLUSTER }} | ||
wait-for-service-stability: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Java CI with Gradle and Deploy to develop EC2 | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
pull_request: | ||
branches: [ "develop" ] | ||
|
||
env: | ||
IMAGE_TAG: ${{ github.sha }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: checkout action with submodule | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.ACTION_TOKEN }} | ||
submodules: true | ||
|
||
- name: Set up JDK 17 action | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Setup Gradle action | ||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 | ||
|
||
- name: add +x permission to gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle Wrapper | ||
run: ./gradlew clean build | ||
|
||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-libs | ||
path: build/libs/*.jar | ||
|
||
deploy: | ||
needs: build | ||
if: github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- name: Checkout action | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Download Build Artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: build-libs | ||
path: build/libs | ||
|
||
- name: Build image and Generate tar | ||
id: build-image | ||
run: | | ||
docker build -t kumoh_talk:$IMAGE_TAG . | ||
docker save kumoh_talk:$IMAGE_TAG -o kumoh_talk:$IMAGE_TAG.tar | ||
- name: Upload to S3 | ||
run: | | ||
aws s3 cp kumoh_talk:$IMAGE_TAG.tar s3://${{ secrets.S3_BUCKET_NAME }}/kumoh_talk:$IMAGE_TAG.tar | ||
- name: SSH Connect | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.DEV_HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.DEV_EC2_PRIVATE_KEY }} | ||
script: | | ||
sudo docker stop spring-boot-app || true | ||
sudo docker rm spring-boot-app || true | ||
aws s3 cp s3://${{ secrets.S3_BUCKET_NAME }}/kumoh_talk:$IMAGE_TAG.tar kumoh_talk:$IMAGE_TAG.tar | ||
sudo docker load -i kumoh_talk:$IMAGE_TAG.tar | ||
sudo docker run -d --log-driver=syslog -e USE_PROFILE=dev -p 8080:8080 kumoh_talk:$IMAGE_TAG | ||
sudo docker image prune -a -f | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,7 @@ out/ | |
.vscode/ | ||
|
||
# 속성 제외 | ||
**/application.properties | ||
**/application.properties | ||
.env | ||
data | ||
.DS_Store |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "src/main/resources/security"] | ||
path = src/main/resources/security | ||
url = https://github.com/Kumoh-talk/kumoh-talk-backend-security.git |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM openjdk:17-jdk-slim | ||
ARG JAR_FILE_PATH=build/libs/*.jar | ||
COPY ${JAR_FILE_PATH} app.jar | ||
ENTRYPOINT ["java", "-Dspring.profiles.active=${USE_PROFILE}", "-jar", "app.jar"] |
Oops, something went wrong.