File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Node.js CI with PR Comment
2+
3+ on :
4+ pull_request :
5+ branches : [ '**' ]
6+
7+ jobs :
8+ test :
9+ runs-on : ubuntu-latest
10+ strategy :
11+ matrix :
12+ node-version : [14.x, 16.x, 18.x]
13+ steps :
14+ - uses : actions/checkout@v2
15+
16+ - name : Use Node.js ${{ matrix.node-version }}
17+ uses : actions/setup-node@v2
18+ with :
19+ node-version : ${{ matrix.node-version }}
20+
21+ - name : Install dependencies
22+ run : yarn install
23+
24+ - name : Run tests and capture output
25+ run : |
26+ mkdir -p test_results
27+ yarn run test > test_results/results.txt 2>&1
28+
29+ - name : Post PR Comment with Test Results
30+ uses : actions/github-script@v5
31+ if : github.event_name == 'pull_request'
32+ with :
33+ github-token : ${{secrets.GITHUB_TOKEN}}
34+ script : |
35+ const fs = require('fs');
36+ const path = 'test_results/results.txt';
37+ const testResults = fs.readFileSync(path, { encoding: 'utf8' });
38+ const commentBody = `🚀 Test Results:\n\`\`\`\n${testResults}\n\`\`\``;
39+ github.rest.issues.createComment({
40+ ...context.repo,
41+ issue_number: context.issue.number,
42+ body: commentBody
43+ });
44+
45+ - name : Archive test results
46+ if : success()
47+ uses : actions/upload-artifact@v2
48+ with :
49+ name : test-results
50+ path : |
51+ test_results/
You can’t perform that action at this time.
0 commit comments