File tree Expand file tree Collapse file tree 1 file changed +34
-4
lines changed Expand file tree Collapse file tree 1 file changed +34
-4
lines changed Original file line number Diff line number Diff line change 1313 test :
1414 name : Run Jest Tests
1515 runs-on : ubuntu-latest
16- permissions :
16+ permissions :
1717 pull-requests : write
1818 contents : read
1919 issues : write
@@ -31,12 +31,42 @@ jobs:
3131 run : npm install
3232
3333 - name : Run Jest Tests
34- run : npm test
34+ id : jest
35+ run : |
36+ npm test -- --json --outputFile=jest-results.json || echo "TESTS_FAILED=true" >> $GITHUB_ENV
37+
38+ - name : Read Jest Results
39+ id : results
40+ run : |
41+ if [ -z "$TESTS_FAILED" ]; then
42+ TESTS_FAILED=false
43+ fi
44+ if [ ! -f jest-results.json ]; then
45+ echo "TESTS_FAILED=true" >> $GITHUB_ENV
46+ fi
47+ if [ "$TESTS_FAILED" = "true" ]; then
48+ echo "TESTS_PASSED=false" >> $GITHUB_ENV
49+ else
50+ echo "TESTS_PASSED=true" >> $GITHUB_ENV
51+ fi
52+ PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH" 2>/dev/null || echo "0")
53+ echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
54+
55+ - name : Comment on PR
56+ if : ${{ github.event_name == 'pull_request' }}
57+ uses : thollander/actions-comment-pull-request@v3
58+ with :
59+ pr-number : ${{ steps.results.outputs.PR_NUMBER }}
60+ github-token : ${{ secrets.GITHUB_TOKEN }}
61+ message : |
62+ ${{ steps.results.outputs.PR_NUMBER }}
63+ ${{ env.TESTS_FAILED == 'true' && '❌ Some Jest tests failed.' || '✅ All Jest tests passed!'}}
3564
3665 deploy :
37- needs : test
66+ name : Deploy to GitHub Pages
3867 runs-on : ubuntu-latest
39- if : ${{ github.repository == 'sugarlabs/musicblocks'}}
68+ needs : test
69+ if : github.repository == 'sugarlabs/musicblocks' && needs.test.outputs.TESTS_PASSED == 'true'
4070
4171 steps :
4272 - name : Checkout repository
You can’t perform that action at this time.
0 commit comments