From f01761f159b0d3fe11ce99a39754b10b00bb1e45 Mon Sep 17 00:00:00 2001 From: Ash Kyd Date: Mon, 14 Aug 2023 13:54:13 +1000 Subject: [PATCH] Github Action for jest tests --- .github/workflow/tests.yml | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflow/tests.yml diff --git a/.github/workflow/tests.yml b/.github/workflow/tests.yml new file mode 100644 index 0000000..24d27aa --- /dev/null +++ b/.github/workflow/tests.yml @@ -0,0 +1,43 @@ +name: Tests CI + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Test using Node.js + uses: actions/setup-node@v1 + with: + node-version: '16' + - run: npm install + - run: yarn test + + - name: Tests ✅ + if: ${{ success() }} + run: | + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "context": "tests", + "state": "success", + "description": "Tests passed", + "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }' + + - name: Tests 🚨 + if: ${{ failure() }} + run: | + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "context": "tests", + "state": "failure", + "description": "Tests failed", + "target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }'