diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a6cafc7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,44 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Node.js CI + +on: + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + + - name: Execute text + run: npm test + + - name: if fail + uses: actions/github-script@v5.0.0 + with: + script: | + const ref = "${{github.ref}}" + const pull_number = Number(ref.split("/")[2]) + await github.pulls.createReview({ + ...context.repo, + pull_number, + body:"테스트가 실패했습니다.", + event: "REQUEST_CHANGES" + }) + await github.pulls.update({ + ...context.repo, + pull_number, + state: "closed" + }) + if: failure() + diff --git a/test.js b/test.js index c0a56df..fe02a56 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ -const evenNumber = 10 +const evenNumber = 11 if (evenNumber % 2 !== 0) { throw '짝수가 아닙니다!'