Skip to content

On Run Publish Surefire Report #1

On Run Publish Surefire Report

On Run Publish Surefire Report #1

name: On Run Publish Surefire Report
on:
workflow_run:
workflows: [On PR Open or Push Do Build and Test]
types: [completed]
jobs:
download:
name: Downloading Surefire report
runs-on: ubuntu-latest
steps:
# Downloading surefire report artifact containing
# zip file with reports and file
# containing commit sha
- name: Download artifact
id: download-artifact
uses: actions/github-script@v7
with:
result-encoding: string
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 == "surefire-test-report"
})[0];
if (typeof matchArtifact == 'undefined') {
// No surefire report artifact found
return "No Report";
}
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}/surefire-test-report.zip`, Buffer.from(download.data));
return "Report Found";
- if: steps.download-artifact.outputs.result == 'Report Found'
name: Unzip artifact
run: unzip surefire-test-report.zip
- name: Get github sha
id: github_sha
uses: juliangruber/read-file-action@v1
with:
path: ./github-sha.txt
- name: Publish Test Report
if: success() || failure()
uses: ScaCap/action-surefire-report@v1
with:
commit: ${{ steps.github_sha.outputs.content }}
check_name: check-ci test report
report_paths: |
**/surefire-reports/TEST-*.xml