Skip to content

Commit

Permalink
Added missing download action
Browse files Browse the repository at this point in the history
  • Loading branch information
smiasojed committed Nov 7, 2023
1 parent cefdb93 commit 31d5d20
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/download-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Download Artifact
description: Download artifact
inputs:
GITHUB_TOKEN:
description: Token for using the GitHub REST API
required: true
ARTIFACT_NAME:
description: Name of the artifact to be downloaded
required: true
DOWNLOAD_DIR:
description: Destination directory
required: false
default: ''

runs:
using: composite
steps:
- name: Download Artifact
uses: actions/github-script@v6
with:
retries: 3
github-token: ${{ inputs.GITHUB_TOKEN }}
script: |
const artifactName = '${{ inputs.ARTIFACT_NAME }}';
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.find((artifact) => artifact.name === artifactName);
if (matchArtifact) {
var 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(`${process.env.GITHUB_WORKSPACE}/data.zip`, Buffer.from(download.data));
} else {
core.setFailed(`Artifact ${artifactName} not found.`);
}
- run: unzip data.zip -d ./${{ inputs.DOWNLOAD_DIR }}
shell: bash

0 comments on commit 31d5d20

Please sign in to comment.