-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
649 additions
and
13 deletions.
There are no files selected for viewing
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,82 @@ | ||
name: AWS CodeDeploy Automation | ||
|
||
on: | ||
push: | ||
branches: | ||
- "deploy/spring" | ||
|
||
env: | ||
AWS_REGION : "ap-northeast-2" | ||
CONTAINER_NAME: "spring-app" | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.ROLE_NAME }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build docker file and setting deploy files | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
- name: Prepare appspec.yml | ||
env: | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
sed -i "s/<AWS_REGION>/${{ env.AWS_REGION }}/g" appspec.yml | ||
sed -i "s/<CONTAINER_NAME>/${{ env.CONTAINER_NAME }}/g" appspec.yml | ||
sed -i "s/<ECR_REGISTRY>/$ECR_REGISTRY/g" appspec.yml | ||
sed -i "s/<ECR_REPOSITORY>/$ECR_REPOSITORY/g" appspec.yml | ||
sed -i "s/<IMAGE_TAG>/$IMAGE_TAG/g" appspec.yml | ||
- name: Make .zip | ||
run: | | ||
zip -r deployment_package.zip ./scripts/* appspec.yml | ||
- name: Upload .zip to Amazon S3 | ||
run: | | ||
aws s3 cp deployment_package.zip s3://${{ secrets.BUCKET_NAME }}/$GITHUB_SHA.zip | ||
- name: Create deployment to AWS CodeDeploy | ||
run: | | ||
aws deploy create-deployment \ | ||
--application-name ${{ secrets.CODEDEPLOY_APP_NAME }} \ | ||
--deployment-config-name CodeDeployDefault.AllAtOnce \ | ||
--deployment-group-name ${{ secrets.DEPLOYMENT_GROUP_NAME }} \ | ||
--s3-location bucket=${{ secrets.BUCKET_NAME }},key=$GITHUB_SHA.zip,bundleType=zip \ | ||
--file-exists-behavior OVERWRITE |
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,41 @@ | ||
HELP.md | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
/data1 | ||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
.DS_Store | ||
|
||
.env |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
FROM nginx | ||
COPY ./index.html /usr/share/nginx/html | ||
FROM openjdk:17 | ||
VOLUME /tmp | ||
ARG JAR_FILE=build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java","-jar", "-Duser.timezone=Asia/Seoul","/app.jar"] |
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
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,58 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '3.2.1' | ||
id 'io.spring.dependency-management' version '1.1.4' | ||
id 'com.diffplug.spotless' version '6.24.0' | ||
} | ||
|
||
group = 'com.healthier' | ||
|
||
java { | ||
sourceCompatibility = '17' | ||
} | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
// implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' | ||
// implementation 'org.springframework.boot:spring-boot-starter-data-redis' | ||
// implementation 'org.springframework.boot:spring-boot-starter-security' | ||
|
||
//swagger | ||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
compileOnly 'org.projectlombok:lombok' | ||
runtimeOnly 'com.mysql:mysql-connector-j' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
testImplementation 'org.springframework.security:spring-security-test' | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
} | ||
|
||
jar { | ||
enabled = false | ||
} | ||
|
||
spotless { | ||
java { | ||
target("**/*.java") | ||
googleJavaFormat().aosp() | ||
importOrder() | ||
removeUnusedImports() | ||
trimTrailingWhitespace() | ||
endWithNewline() | ||
} | ||
} |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.