Skip to content

Publish reports

Publish reports #180

name: Publish reports
on:
workflow_run:
workflows: ["Build And Test"]
types:
- completed
jobs:
publish:
name: Publish Test Report
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id}},
});
for (var artifact of artifacts.data.artifacts) {
if (artifact.name.endsWith('test-reports')) {
var zipfile = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
var fs = require('fs');
var path = require('path');
var pathFile = path.format({
root: '${{github.workspace}}/',
name: artifact.name,
ext: '.zip'
});
fs.writeFileSync(pathFile, Buffer.from(zipfile.data));
}
}
- name: Unzip artifacts
run: |
find . -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;
- name: Publish aggregated tests reports
uses: scacap/action-surefire-report@4cbb611f23a9b5a030c73c2b32190a80983956ed #v1
with:
github_token: ${{secrets.GITHUB_TOKEN}}
report_paths: '${{github.workspace}}/*test-reports/**/TEST-*.xml'
commit: ${{github.event.workflow_run.head_sha}}