-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
45 lines (44 loc) · 1.64 KB
/
action.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
name: "Transfer Workflow Artifact"
description: "Copies an artifact from the upstream workflow into this one."
inputs:
name:
description: "Name of the artifact to retrieve."
required: true
runs:
using: "composite"
steps:
- name: 'Download artifacts from triggering workflow'
uses: actions/github-script@v7
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 matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == '${{ inputs.name }}';
});
let downloadsPromises = matchArtifacts.map(async (artifact) => {
var blob = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip'
});
return { name: artifact.name, data: blob.data }
});
let downloads = await Promise.all(downloadsPromises);
let fs = require('fs');
downloads.forEach((download) => {
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/${download.name}.zip`, Buffer.from(download.data));
});
- name: Unzip ${{ inputs.name }}
shell: pwsh
run: Expand-Archive -Path "${{ inputs.name }}.zip" -DestinationPath ./${{ inputs.name }}/
- name: "Upload '/${{ inputs.name }}'"
uses: actions/upload-artifact@v3
with:
name: "${{ inputs.name }}"
path: "./${{ inputs.name }}/"
if-no-files-found: error