개발지식/오픈소스

260107 오픈소스 프로젝트 만들어보기

thinktank911 2026. 1. 6. 22:17

오픈소스 프로젝트 만들어보기

오픈소스 프로젝트 주제 선정

가장 좋은 오픈소스는 개발 과정에 필요성을 해소하는 주제
주제가 없다면

  • 복잡한 구동과정 없이 결과를 확인할 수 있음
  • 확장성이 있는 기능
    • lodash.js
    • underscore.js
    • immer.js

소스코드 작업

  • npm 패키지 셋팅
    npm init -y

PR 관리를 위한 github action 설정

github actions 란?

  • GitHub에서 제공하는 빌드, 테스트 및 배포 파이프라인을 자동화할 수 있는 CI/CD 서비스
  • CI(Continuous Integration, 지속 통합)와 CD(Continuous Deployment, 지속 배포)
  • .github/workflows 폴더에 yml 파일로 정의
name: Pull Request Check  # 워크플로우 이름

on:  # 워크플로우 실행 트리거
  pull_request:  # pull_request가 실행될 때만
    types: [opened, synchronize]  # PR이 생성되거나 업데이트 될 때

jobs:  # 작업 정의
  check:
    runs-on: ubuntu-latest  # 우분투 환경
    permissions:  # 권한 설정
      pull-requests: write  # PR에 쓰기 권한 설정
      issues: write
    steps:  # 작업 단계
      - uses: actions/github-script@v7
        with:
          script: | # 스크립트 시작
            async function run() {
              const pull_request = context.payload.pull_request; // pull_request 객체 가져오기

              if(pull_request === undefined) {  // pull_request가 없는 경우
                console.log("This is not a pull request");  // "This is not a pull request" 출력
                return;  // 종료
              }

              const body = pull_request.body;  // 본문 담기

              const message = "아래 기입 내용을 작성해주시고 해당 라인을 삭제해주세요"

              if(!body || body.includes(message)){
                try {
                  // PR에 코멘트를 추가합니다.
                  await github.rest.issues.createComment({  // PR에 코멘트 추가
                    owner: context.repo.owner,  // 저장소 소유자
                    repo: context.repo.repo,  // 저장소 이름
                    issue_number: pull_request.number,  // PR 번호
                    body: "해당 PR은 가이드라인을 준수하지 않았습니다.",  // 코멘트 내용
                  });

                  // PR을 닫습니다.
                  await github.rest.pulls.update({  // PR을 닫음
                    owner: context.repo.owner,  // 저장소 소유자
                    repo: context.repo.repo,  // 저장소 이름
                    pull_number: pull_request.number,  // PR 번호
                    state: "closed",  // 상태를 닫힘으로 변경
                  });
                } catch (error) {
                  console.error("Error occurred while closing PR:", error);  // 오류 메세지 출력
                }
              }
            };

            run();