Skip to content

Commit

Permalink
Update script action version and code
Browse files Browse the repository at this point in the history
Some api changes and better variable naming.

b/290997541
  • Loading branch information
oxve committed Jul 17, 2023
1 parent 6fa729b commit 29feea3
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/unit_test_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,29 @@ jobs:
steps:
- name: Collect Unit Test Reports
id: collect-report
uses: actions/github-script@v6.4.1
uses: actions/github-script@v6
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
var results = artifacts.data.artifacts.filter((artifact) => {
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "unit-test-results"
});
if (results.length == 0) {
// No reports to upload.
if (matchArtifact.length == 0) {
// No reports were uploaded.
return false;
}
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: results.id,
archive_format: 'zip',
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/unit-test-results.zip', Buffer.from(download.data));
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/unit-test-results.zip`, Buffer.from(download.data));
return true;
- run: unzip unit-test-results.zip -d unit-test-results
if: steps.collect-report.outputs.result
Expand Down

0 comments on commit 29feea3

Please sign in to comment.