From 9358641e345655f8dad90196bbc07f130e79b843 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 26 Mar 2024 02:29:44 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20ci=20workflow=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 57 ++++++++++++++++++++++++++++++++++++++ gradlew | 0 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/test.yml mode change 100644 => 100755 gradlew diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..a16b8107e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,57 @@ +name: Continuous Integration + +on: + pull_request: + branches: [ "dev" ] + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + environment: + description: 'Environment to run tests against' + type: environment + required: false + +permissions: + contents: read + +jobs: + testing: + runs-on: ubuntu-20.04 + + steps: + # 1. Compare branch 코드 내려 받기 + - name: Checkout PR + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + + # 2. 자바 환경 설정 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + # 3. Testing을 위한 MySQL 설정 + - name: Setup MySQL + uses: mirromutth/mysql-action@v1.1 + with: + mysql database: ${{ secrets.MYSQL_TEST_DATABASE }} + mysql user: ${{ secrets.MYSQL_TEST_USER }} + mysql password: ${{ secrets.MYSQL_TEST_PASSWORD }} + + # 4. Gradle Test 실행 + - name: Test with Gradle + run: ./gradlew --info test \ No newline at end of file diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From af68ef0dba6384a9fb372c8ae7849751825c94d3 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 26 Mar 2024 02:54:10 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20cd=20workflow=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..37b245492 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,68 @@ +name: Continuous Deployment + +on: + push: + branches: [ "develop" ] + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + environment: + description: 'Environment to run tests against' + type: environment + required: false + +permissions: + contents: read + +jobs: + deployment: + runs-on: ubuntu-20.04 + + steps: + # 1. Compare branch 코드 내려 받기 + - name: Checkout PR + uses: actions/checkout@v3 + with: + ref: ${{ github.event.push.base_ref }} + + # 2. 자바 환경 설정 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + # 3. Docker 이미지 build 및 push + - name: docker build and push + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t jinlee1703/pennyway-was . + docker push jinlee1703/pennyway-was:${{env.IMAGE_TAG}} + + # 4. AWS SSM을 통한 Run-Command (Docker 이미지 pull 후 docker-compose를 통한 실행) + - name: AWS SSM Send-Command + uses: peterkimzz/aws-ssm-send-command@master + id: ssm + with: + aws-region: ${{ secrets.AWS_REGION }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + instance-ids: ${{ secrets.AWS_DEV_INSTANCE_ID }} + working-directory: /home/ubuntu + command: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker system prune -a -f + docker pull jinlee1703/pennyway-was + docker-compose up -d \ No newline at end of file From 95805380c0938fdd7c45d7f8c8d661e572bf5f6f Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 26 Mar 2024 10:34:31 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20mysql=20actions=20step=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a16b8107e..200219117 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,14 +44,6 @@ jobs: java-version: '17' distribution: 'temurin' - # 3. Testing을 위한 MySQL 설정 - - name: Setup MySQL - uses: mirromutth/mysql-action@v1.1 - with: - mysql database: ${{ secrets.MYSQL_TEST_DATABASE }} - mysql user: ${{ secrets.MYSQL_TEST_USER }} - mysql password: ${{ secrets.MYSQL_TEST_PASSWORD }} - - # 4. Gradle Test 실행 + # 3. Gradle Test 실행 - name: Test with Gradle run: ./gradlew --info test \ No newline at end of file From 9ab3b933d0db144a91a4f85c2e0137701226d805 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 26 Mar 2024 11:40:55 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20docker=20image=20=ED=83=9C=EA=B7=B8?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 37b245492..bcaf17a6b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,7 +49,7 @@ jobs: run: | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} docker build -t jinlee1703/pennyway-was . - docker push jinlee1703/pennyway-was:${{env.IMAGE_TAG}} + docker push jinlee1703/pennyway-was # 4. AWS SSM을 통한 Run-Command (Docker 이미지 pull 후 docker-compose를 통한 실행) - name: AWS SSM Send-Command From b6b3c9555d1c58bc705febd79ab999613bca3d38 Mon Sep 17 00:00:00 2001 From: Jinwoo Lee Date: Tue, 26 Mar 2024 13:28:40 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20cd=20=ED=8C=8C=EC=9D=B4=ED=94=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20trigger=20=EB=B8=8C=EB=9E=9C=EC=B9=98?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95(develop->dev)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bcaf17a6b..4fe85d304 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -2,7 +2,7 @@ name: Continuous Deployment on: push: - branches: [ "develop" ] + branches: [ "dev" ] workflow_dispatch: inputs: logLevel: