Skip to content

Commit

Permalink
Merge pull request #90 from boostcampwm-2024/Feature/#085_Github_Acti…
Browse files Browse the repository at this point in the history
…ons_설정

Feature/#85 Github Actions workflow 추가
  • Loading branch information
hyonun321 authored Nov 11, 2024
2 parents f276905 + 804399f commit 318e649
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/auto_merge_approved_pr.yml
Original file line number Diff line number Diff line change
@@ -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,
});
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 318e649

Please sign in to comment.