From d5bd75a7b9e931372422fb1b28e92fb3dc7fe306 Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Sun, 10 Nov 2024 21:57:04 +0900 Subject: [PATCH 1/3] =?UTF-8?q?ci:=20main,=20dev=20=EB=B8=8C=EB=9E=9C?= =?UTF-8?q?=EC=B9=98=EC=97=90=20push=ED=95=A0=20=EB=95=8C=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=EC=9C=BC=EB=A1=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=ED=96=89=ED=95=98=EB=8A=94=20workflow=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #085 --- .github/workflows/lint_and_test.yml | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/lint_and_test.yml diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml new file mode 100644 index 00000000..aba7d3b4 --- /dev/null +++ b/.github/workflows/lint_and_test.yml @@ -0,0 +1,43 @@ +name: Lint and Test + +on: + push: + branches: + - main + - dev + pull_request: + branches: + - main + - dev + +jobs: + lint-and-test: + name: Lint and Test + runs-on: ubuntu-latest + + steps: + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v4 + + # Install pnpm + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + run_install: true + + # Set up Node.js + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "pnpm" + + # Run lint + - name: Run lint + run: pnpm eslint . + + # Run tests + - name: Run tests + run: pnpm test From 7dd1d351594339fa0b806961ab4aa4e19a34d23e Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Sun, 10 Nov 2024 22:56:13 +0900 Subject: [PATCH 2/3] =?UTF-8?q?ci:=202=EB=AA=85=20=EC=9D=B4=EC=83=81?= =?UTF-8?q?=EC=9D=B4=20approve=ED=95=9C=20PR=EC=9D=84=20=EC=9E=90=EB=8F=99?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20merge=ED=95=98=EB=8A=94=20workflow=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #085 --- .github/workflows/auto_merge_approved_pr.yml | 45 ++++++++++++++++++++ .github/workflows/deploy.yml | 4 +- .github/workflows/lint_and_test.yml | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/auto_merge_approved_pr.yml diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml new file mode 100644 index 00000000..2870bbf7 --- /dev/null +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -0,0 +1,45 @@ +name: "Auto Merge Approved PRs" + +on: + pull_request_review: + types: [submitted] + +jobs: + auto_merge: + runs-on: ubuntu-latest + steps: + - name: "Get Pull Request" + id: pr + uses: actions/github-script@v6 + with: + result-encoding: string + script: | + const { data: pr } = await github.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + return JSON.stringify(pr); + - name: "Check Approvals" + id: check + uses: actions/github-script@v6 + with: + script: | + const pr = JSON.parse(steps.pr.outputs.result); + const reviews = await github.pulls.listReviews({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + }); + const approvals = reviews.data.filter(review => review.state === 'APPROVED'); + return approvals.length >= 2; + - name: "Merge PR" + if: steps.check.outputs.result == 'true' + uses: actions/github-script@v6 + with: + script: | + await github.pulls.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3e829ab0..d8e1f75f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,11 +12,11 @@ jobs: steps: # 1. 레포지토리 클론 - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # 2. Docker Compose로 서비스 빌드 및 재시작 - name: Set up Docker - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and Deploy Docker Images run: | diff --git a/.github/workflows/lint_and_test.yml b/.github/workflows/lint_and_test.yml index aba7d3b4..63f6decc 100644 --- a/.github/workflows/lint_and_test.yml +++ b/.github/workflows/lint_and_test.yml @@ -11,7 +11,7 @@ on: - dev jobs: - lint-and-test: + lint_and_test: name: Lint and Test runs-on: ubuntu-latest From 804399f949df90fdb31e9526f796ca18778475d7 Mon Sep 17 00:00:00 2001 From: minjungw00 Date: Mon, 11 Nov 2024 10:29:05 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20audo=5Fmerge=5Fapprove=5Fpr.yml=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto_merge_approved_pr.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml index 2870bbf7..3c755913 100644 --- a/.github/workflows/auto_merge_approved_pr.yml +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -12,9 +12,10 @@ jobs: id: pr uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} result-encoding: string script: | - const { data: pr } = await github.pulls.get({ + const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number, @@ -24,21 +25,23 @@ jobs: id: check uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const pr = JSON.parse(steps.pr.outputs.result); - const reviews = await github.pulls.listReviews({ + const reviews = await github.rest.pulls.listReviews({ owner: context.repo.owner, repo: context.repo.repo, pull_number: pr.number, }); const approvals = reviews.data.filter(review => review.state === 'APPROVED'); - return approvals.length >= 2; + core.setOutput('result', approvals.length >= 2); - name: "Merge PR" - if: steps.check.outputs.result == 'true' + if: steps.check.outputs.result uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | - await github.pulls.merge({ + await github.rest.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number,