playwright/.github/actions/download-artifact/action.yml
Yury Semikhatsky 972ad89af2
feat(devops): publish merged reports to pull requests (#23419)
* Moved report merging and publishing logic into create_test_report.yml
shared between all workflows
* Merged reports are now published for try jobs on pull requests too. In
order to achieve that the logic had to be extracted into a separate
workflow triggered by
[workflow_run](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run),
this way it can access secrets even if the original workflow was not
able to.
* The blob report data flow is different depending on whether the
workflow is triggered by a pull request or a push:
- For `pull_request` the workflow doesn't have access to the secrets it
uploads the blob report to the GitHub
artifact storage. Later on the merge workflow uploads that blob report
to Azure blob storage.
- Workflows triggered by `push` event can read secrets. They upload blob
report directly to Azure blob storage
and the merge workflow downloads the report from there rather than from
GitHub artifacts.
2023-06-01 08:40:43 -07:00

41 lines
1.4 KiB
YAML

name: 'Download blob report'
description: 'Download blob report from GitHub artifacts'
inputs:
name:
description: 'Name of the artifact to download'
required: true
type: string
default: 'blob-report'
path:
description: 'Directory with downloaded artifacts'
required: true
type: string
default: 'blob-report'
runs:
using: "composite"
steps:
- name: Download blob report
uses: actions/github-script@v6
with:
script: |
console.log(`downloading artifacts for workflow_run: ${context.payload.workflow_run.id}`);
console.log(`workflow_run: ${JSON.stringify(context.payload.workflow_run, null, 2)}`);
const { data } = await github.rest.actions.listWorkflowRunArtifacts({
...context.repo,
run_id: context.payload.workflow_run.id
});
console.log('total = ', data.total_count);
const name = '${{ inputs.name }}';
const report = data.artifacts.filter(a => a.name === name)[0];
const result = await github.rest.actions.downloadArtifact({
...context.repo,
artifact_id: report.id,
archive_format: 'zip'
});
console.log('download result', result);
const fs = require('fs');
fs.writeFileSync(`${name}.zip`, Buffer.from(result.data));
- name: Unzip blob report
shell: bash
run: unzip ${{ inputs.name }}.zip -d ${{ inputs.path }}