From a1c301197771f68d9cf43517b1b081ea0796768b Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 20:56:03 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20self=20hosted=20runner=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 988de01a..b0c91ed3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted permissions: contents: read packages: write From c0e5e4d76913e8bb8e0a96844801bfd47c8b1fd6 Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 21:39:14 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20CD=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=9E=91=EC=84=B1=20=EB=B0=8F=20Self=20Hosted=20Ru?= =?UTF-8?q?nner=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 66 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000..36e1a54d --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,66 @@ +# 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 package using Gradle and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle + +name: Gradle Package + +on: + pull_request: + types: [ closed ] + branches: [ 'main' ] + +jobs: + build: + runs-on: self-hosted + permissions: + contents: read + packages: write + actions: write + + steps: + - uses: actions/checkout@v4 + - name: Early exit + if: ${{ !contains(github.event.pull_request.labels.*.name, '백엔드') }} + run: | + gh run cancel ${{ github.run_id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-java@v4 + with: + distribution: 'corretto' + java-version: '21' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + + - name: Setup Gradle + run: chmod +x ./backend/gradlew + + - name: Build with Gradle + continue-on-error: true + id: gradle_build + run: | + cd backend + ./gradlew build + + - name: slack mention + uses: slackapi/slack-github-action@v1.24.0 + with: + channel-id: ${{ secrets.ISSUE_CHANNEL }} + payload: | + { + "text": "pr 머지", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "<@channel> pr이 main에 머지되었습니다. \n • PR 링크: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>" + } + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0c91ed3..988de01a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: jobs: build: - runs-on: self-hosted + runs-on: ubuntu-latest permissions: contents: read packages: write From 1fbbaa099aefc910805dbf62decf0e3e9e716042 Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 21:45:58 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20CI=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/front_ci.yml | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/front_ci.yml diff --git a/.github/workflows/front_ci.yml b/.github/workflows/front_ci.yml new file mode 100644 index 00000000..76eb2e4c --- /dev/null +++ b/.github/workflows/front_ci.yml @@ -0,0 +1,69 @@ +name: CI + +on: + pull_request: + types: [ opened, reopened, synchronize ] + branches: [ 'main' ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + task: [lint, build, test] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Early exit + if: ${{ contains(github.event.pull_request.labels.*.name, '백엔드') }} + run: | + gh run cancel ${{ github.run_id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.15.1' + + - name: Install dependencies + run: npm install + + - name: Run ${{ matrix.task }} + id: npm_run + run: npm run ${{ matrix.task }} + + - name: Get teamMember List + id: teamMembers + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + const workers = JSON.parse(fs.readFileSync('.github/workflows/teamMember.json')); + const mention = context.payload.pull_request.assignees.map((user) => { + const login = user.login; + const mappedValue = workers[login]; + return mappedValue ? `<@${mappedValue}>` : `No mapping found for ${login}`; + }) + return mention.join(', '); + + - name: slack mention + uses: slackapi/slack-github-action@v1.24.0 + with: + channel-id: ${{ secrets.ISSUE_CHANNEL }} + payload: | + { + "text": "pr 테스트 결과", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "pr 테스트 ${{ steps.npm_run.outcome}} \n • 링크: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> \n • pr 담당자: \${{ steps.teamMembers.outputs.result }} + } + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} From 9394d085a0a8a1cf1f573dd2b4e7678f8cc850d5 Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 21:49:58 +0900 Subject: [PATCH 4/7] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20CI=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/front_ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/front_ci.yml b/.github/workflows/front_ci.yml index 76eb2e4c..3eccae74 100644 --- a/.github/workflows/front_ci.yml +++ b/.github/workflows/front_ci.yml @@ -8,6 +8,10 @@ on: jobs: build-and-test: runs-on: ubuntu-latest + permissions: + contents: read + packages: write + actions: write strategy: matrix: task: [lint, build, test] @@ -28,11 +32,15 @@ jobs: node-version: '20.15.1' - name: Install dependencies - run: npm install + run: | + cd frontend + npm install - name: Run ${{ matrix.task }} id: npm_run - run: npm run ${{ matrix.task }} + run: | + cd frontend + npm run ${{ matrix.task }} - name: Get teamMember List id: teamMembers From 18e324e410711b1c03f1808a481850ab62f6b1db Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 21:51:46 +0900 Subject: [PATCH 5/7] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20CI=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=EC=8B=9C=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=A4=91?= =?UTF-8?q?=EC=A7=80=EB=90=98=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/front_ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/front_ci.yml b/.github/workflows/front_ci.yml index 3eccae74..61403083 100644 --- a/.github/workflows/front_ci.yml +++ b/.github/workflows/front_ci.yml @@ -37,6 +37,7 @@ jobs: npm install - name: Run ${{ matrix.task }} + continue-on-error: true id: npm_run run: | cd frontend From 522806cadf388bf17a3c601b3acdc9362f46c349 Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 22:00:55 +0900 Subject: [PATCH 6/7] =?UTF-8?q?test:=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 36e1a54d..6071fbf1 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -64,3 +64,4 @@ jobs: } env: SLACK_BOT_TOKEN: ${{ secrets.BOT_TOKEN }} + From c699dd931ca0784954fd16b6b861a2e1d83f6b0e Mon Sep 17 00:00:00 2001 From: robinjoon Date: Thu, 18 Jul 2024 22:07:53 +0900 Subject: [PATCH 7/7] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=A0=ED=8A=B8=20CI=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=20=EC=8A=AC=EB=9E=99=20=EB=A9=94=EC=84=B8?= =?UTF-8?q?=EC=A7=80=EA=B0=80=20=EC=97=AC=EB=9F=AC=EB=B2=88=20=EB=B0=9C?= =?UTF-8?q?=EC=86=A1=EB=90=98=EB=8A=94=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/front_ci.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/front_ci.yml b/.github/workflows/front_ci.yml index 61403083..4a846e40 100644 --- a/.github/workflows/front_ci.yml +++ b/.github/workflows/front_ci.yml @@ -12,9 +12,7 @@ jobs: contents: read packages: write actions: write - strategy: - matrix: - task: [lint, build, test] + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -36,12 +34,27 @@ jobs: cd frontend npm install - - name: Run ${{ matrix.task }} + - name: Run lint + continue-on-error: true + id: npm_run_lint + run: | + cd frontend + npm run lint + + - name: Run build + continue-on-error: true + id: npm_run_build + run: | + pwd + cd frontend + npm run build + + - name: Run test continue-on-error: true - id: npm_run + id: npm_run_test run: | cd frontend - npm run ${{ matrix.task }} + npm run test - name: Get teamMember List id: teamMembers @@ -69,7 +82,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "pr 테스트 ${{ steps.npm_run.outcome}} \n • 링크: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> \n • pr 담당자: \${{ steps.teamMembers.outputs.result }} + "text": "pr 테스트 \n lint : ${{ steps.npm_run_lint.outcome}} \n build : ${{ steps.npm_run_build.outcome}} \n test : ${{ steps.npm_run_test.outcome}} \n • 링크: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> \n • pr 담당자: \${{ steps.teamMembers.outputs.result }} } } ]