-
Notifications
You must be signed in to change notification settings - Fork 42
53 lines (47 loc) · 1.98 KB
/
publish-jest-results.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# This workflow will publish the Jest unit test results and retain them for a period of 30 days. This also gives permission
# to forked repositories and dependabots to do write operations which are configured in this workflow.
name: Publish Jest Results
on:
workflow_run:
workflows: [buildNPM Snapshot, buildNPM Release]
types: [completed]
jobs:
publish-jest-results:
env:
JEST_JUNIT_OUTPUT_DIR: 'artifacts/jest-junit'
runs-on: ubuntu-latest
steps:
- name: Download test results artifact
if: ${{github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'push'}}
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "jest-test-results"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/jest-test-results.zip`, Buffer.from(download.data));
- name: Unzip Test Results
id: unzip-test-res
run: unzip jest-test-results.zip
- name: Publish Jest unit test results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_name: ${{ github.event.workflow_run.event }}
files: "junit.xml"
check_name: Jest Unit Test Results
comment_mode: off
comment_title: Jest Unit Test Results