Skip to content

Commit

Permalink
Use got to fetch artifact URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 15, 2021
1 parent 1f5bb98 commit 52024f7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
14 changes: 11 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,24 @@ export async function downloadArtifact(
try {
core.info(`Artifact ID: ${artifactId}`)

const resp = await octokit.actions.downloadArtifact({
const req = octokit.actions.downloadArtifact.endpoint({
...github.context.repo,
artifact_id: artifactId,
archive_format: 'zip'
})

core.info(`Fetch artifact URL: ${resp.status}`)
const url = resp.headers.Location
const resp = await got({
url: req.url,
headers: req.headers as {[header: string]: string},
followRedirect: false
})

core.info(`Fetch artifact URL: ${resp.statusCode} ${resp.statusMessage}`)
if (resp.statusCode !== 302) {
throw new Error('Fetch artifact URL failed: received unexpected status code')
}

const url = resp.headers.location
if (url === undefined) {
const headers = Object.keys(resp.headers)
core.info(`Received headers: ${headers.join(', ')}`)
Expand Down

0 comments on commit 52024f7

Please sign in to comment.