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