diff --git a/.github/workflows/auto_merge_approved_pr.yml b/.github/workflows/auto_merge_approved_pr.yml new file mode 100644 index 00000000..3c755913 --- /dev/null +++ b/.github/workflows/auto_merge_approved_pr.yml @@ -0,0 +1,48 @@ +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: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + const { data: pr } = await github.rest.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: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const pr = JSON.parse(steps.pr.outputs.result); + 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'); + core.setOutput('result', approvals.length >= 2); + - name: "Merge PR" + if: steps.check.outputs.result + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.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 new file mode 100644 index 00000000..63f6decc --- /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