diff --git a/.github/workflows/prod-3-cicd.yml b/.github/workflows/prod-apigateway-deploy.yml similarity index 96% rename from .github/workflows/prod-3-cicd.yml rename to .github/workflows/prod-apigateway-deploy.yml index 21d1676..c024465 100644 --- a/.github/workflows/prod-3-cicd.yml +++ b/.github/workflows/prod-apigateway-deploy.yml @@ -9,9 +9,9 @@ name: Java CI with Gradle on: push: - branches: [ "prod-1" ] + branches: [ "prod-apigateway" ] pull_request: - branches: [ "prod-1" ] + branches: [ "prod-apigateway" ] jobs: build: diff --git a/.github/workflows/prod-community-deploy.yml b/.github/workflows/prod-community-deploy.yml new file mode 100644 index 0000000..2f1dfe5 --- /dev/null +++ b/.github/workflows/prod-community-deploy.yml @@ -0,0 +1,70 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: CommunityService + +on: + push: + branches: [ "prod-community" ] + pull_request: + branches: [ "prod-community" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Make application.yml + run: | + mkdir -p src/main/resources + echo "$APPLICATION_COMMUNITY" > src/main/resources/application.yml + env: + APPLICATION: ${{ secrets.APPLICATION_COMMUNITY }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Docker build + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t app . + docker tag app ${{ secrets.DOCKER_USERNAME }}/community:latest + docker push ${{ secrets.DOCKER_USERNAME }}/community:latest + + - name: docker-compose.yml + uses: appleboy/scp-action@master + with: + username: ec2-user + host: ${{ secrets.HOST }} + key: ${{ secrets.PRIVATE_KEY_3 }} + port: ${{ secrets.PORT }} + source: "./docker-compose-community.yml" + target: "/home/ec2-user/" + + - name: Deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST_PROD_3 }} + username: ec2-user + key: ${{ secrets.PRIVATE_KEY_3 }} + script: | + docker pull ${{ secrets.DOCKER_USERNAME }}/community:latest + docker image prune -a -f + docker-compose up -d diff --git a/.github/workflows/prod-contents-deploy.yml b/.github/workflows/prod-contents-deploy.yml new file mode 100644 index 0000000..90040b0 --- /dev/null +++ b/.github/workflows/prod-contents-deploy.yml @@ -0,0 +1,69 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "prod-contents" ] + pull_request: + branches: [ "prod-contents" ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Clean Gradle Cache + run: ./gradlew clean + + - name: Make application.yml + run: | + mkdir -p src/main/resources + echo "$APPLICATION" > src/main/resources/application.yml + env: + APPLICATION: ${{ secrets.APPLICATION_CONTENTS }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Docker build + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t app . + docker tag app ${{ secrets.DOCKER_USERNAME }}/contents:latest + docker push ${{ secrets.DOCKER_USERNAME }}/contents:latest + + - name: docker-compose.yml + uses: appleboy/scp-action@master + with: + username: ec2-user + host: ${{ secrets.HOST_PROD_2 }} + key: ${{ secrets.PRIVATE_KEY_CONTENTS }} + port: ${{ secrets.PORT }} + source: "./docker-compose-contents.yml" + target: "/home/ec2-user/" + + - name: Deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST_CONTENTS }} + username: ec2-user + key: ${{ secrets.PRIVATE_KEY_CONTENTS }} + script: | + docker pull ${{ secrets.DOCKER_USERNAME }}/contents:latest + docker image prune -a -f + docker-compose up -dons/dependency-submission@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 diff --git a/.github/workflows/prod-1-cicd.yml b/.github/workflows/prod-eureka-deploy.yml similarity index 97% rename from .github/workflows/prod-1-cicd.yml rename to .github/workflows/prod-eureka-deploy.yml index 21d1676..722ba15 100644 --- a/.github/workflows/prod-1-cicd.yml +++ b/.github/workflows/prod-eureka-deploy.yml @@ -9,9 +9,9 @@ name: Java CI with Gradle on: push: - branches: [ "prod-1" ] + branches: [ "prod-eureka" ] pull_request: - branches: [ "prod-1" ] + branches: [ "prod-eureka" ] jobs: build: diff --git a/.github/workflows/prod-2-cicd.yml b/.github/workflows/prod-keyword-deploy.yml similarity index 97% rename from .github/workflows/prod-2-cicd.yml rename to .github/workflows/prod-keyword-deploy.yml index 1058c13..f753839 100644 --- a/.github/workflows/prod-2-cicd.yml +++ b/.github/workflows/prod-keyword-deploy.yml @@ -9,9 +9,9 @@ name: Java CI with Gradle on: push: - branches: [ "prod-2" ] + branches: [ "prod-keyword" ] pull_request: - branches: [ "prod-2" ] + branches: [ "prod-keyword" ] jobs: build: diff --git a/.github/workflows/prod-member-deploy.yml b/.github/workflows/prod-member-deploy.yml new file mode 100644 index 0000000..2ccc6ed --- /dev/null +++ b/.github/workflows/prod-member-deploy.yml @@ -0,0 +1,70 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: MemberService + +on: + push: + branches: [ "prod-member" ] + pull_request: + branches: [ "prod-member" ] + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Make application.yml + run: | + mkdir -p src/main/resources + echo "$APPLICATION_MEMBER" > src/main/resources/application.yml + env: + APPLICATION: ${{ secrets.APPLICATION_MEMBER }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build -x test + + - name: Docker build + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t app . + docker tag app ${{ secrets.DOCKER_USERNAME }}/member:latest + docker push ${{ secrets.DOCKER_USERNAME }}/member:latest + + - name: docker-compose.yml + uses: appleboy/scp-action@master + with: + username: ec2-user + host: ${{ secrets.HOST }} + key: ${{ secrets.PRIVATE_KEY_3 }} + port: ${{ secrets.PORT }} + source: "./docker-compose-member.yml" + target: "/home/ec2-user/" + + - name: Deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST_PROD_3 }} + username: ec2-user + key: ${{ secrets.PRIVATE_KEY_3 }} + script: | + docker pull ${{ secrets.DOCKER_USERNAME }}/member:latest + docker image prune -a -f + docker-compose up -d diff --git a/README.md b/README.md new file mode 100644 index 0000000..d097c10 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +## 광장 리팩토링✨💗