diff --git a/.github/workflows/workflow-pr.yml b/.github/workflows/workflow-pr.yml new file mode 100644 index 0000000..865a1df --- /dev/null +++ b/.github/workflows/workflow-pr.yml @@ -0,0 +1,56 @@ +name: Production-Build-CI + +on: + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout source code. + uses: actions/checkout@v2 + + # node 버전 환경 설정 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: yarn install --frozen-lockfile + + - name: Build + run: yarn build + + # 빌드 실패한 경우에만 실행되는 step + - name: if build fail + if: ${{ failure() }} + uses: actions/github-script@v6 + with: + github-token: ${{ github.token }} + script: | + const pull_number = ${{ github.event.pull_request.number }} + const updated_title = `[BUILD FAIL] ${{ github.event.pull_request.title }}` + + await github.rest.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull_number, + body: '빌드에 실패했습니다.', + event: 'REQUEST_CHANGES' + }) + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull_number, + title: updated_title, + state: 'closed' + })