forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdownload_pr_artifact.js
More file actions
26 lines (20 loc) · 874 Bytes
/
download_pr_artifact.js
File metadata and controls
26 lines (20 loc) · 874 Bytes
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
module.exports = async ({github, context, core}) => {
const fs = require('fs');
const workflowRunId = process.env.WORKFLOW_ID;
core.info(`Listing artifacts for workflow run ${workflowRunId}`);
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: workflowRunId,
});
const matchArtifact = artifacts.data.artifacts.filter(artifact => artifact.name == "pr")[0];
core.info(`Downloading artifacts for workflow run ${workflowRunId}`);
const artifact = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
core.info("Saving artifact found", artifact);
fs.writeFileSync('pr.zip', Buffer.from(artifact.data));
}