This commit is contained in:
Konrad Pabjan
2023-10-27 17:40:12 -04:00
parent 324d9f15de
commit 499890a085
4 changed files with 51 additions and 11 deletions

30
dist/index.js generated vendored
View File

@@ -9866,12 +9866,10 @@ async function processRuntimeResponse(res, requestOptions) {
}
async function getArtifactMetadata({ githubToken, runId, artifactName }) {
core.info("Creating octokit")
const octokit = github.getOctokit(githubToken)
core.info("Octokit created")
try {
core.info(`Fetching artifact metadata for run ${runId} and name ${artifactName}...`)
core.info(`Fetching artifact metadata for ${artifactName} in run ${runId}`)
const response = await octokit.request("GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts?name={artifactName}", {
owner: github.context.repo.owner,
@@ -9880,7 +9878,27 @@ async function getArtifactMetadata({ githubToken, runId, artifactName }) {
artifactName: artifactName
})
return response.data
const artifactCount = response.data.total_count
core.debug(`List artifact count: ${artifactCount}`)
if (artifactCount === 0) {
throw new Error(`No artifacts found for workflow run ${runId}. Ensure artifacts are uploaded with actions/artifact@v4 or later.`)
} else if (artifactCount > 1) {
throw new Error(`Multiple artifact unexpectedly found for workflow run ${runId}. Artifact count is ${artifactCount}.`)
}
const artifact = response.data.artifacts[0]
core.debug(`Artifact: ${JSON.stringify(artifact)}`)
const artifactSize = artifact.size_in_bytes
if (!artifactSize) {
core.warning('Artifact size was not found. Unable to verify if artifact size exceeds the allowed size.')
}
return {
id: artifact.id,
size: artifactSize
}
} catch (error) {
core.error('Fetching artifact metadata failed', error)
throw error
@@ -10097,7 +10115,7 @@ class Deployment {
this.startTime = null
}
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
// Ask the runtime for and artifact id and deploy to GitHub Pages
// by creating a deployment with that artifact
async create(idToken) {
if (Number(core.getInput('timeout')) > MAX_TIMEOUT) {
@@ -10123,6 +10141,8 @@ class Deployment {
console.log(artifactData)
// TODO create deployment
return
} catch (error) {
core.error(error.stack)

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -55,12 +55,10 @@ async function processRuntimeResponse(res, requestOptions) {
}
async function getArtifactMetadata({ githubToken, runId, artifactName }) {
core.info("Creating octokit")
const octokit = github.getOctokit(githubToken)
core.info("Octokit created")
try {
core.info(`Fetching artifact metadata for run ${runId} and name ${artifactName}...`)
core.info(`Fetching artifact metadata for ${artifactName} in run ${runId}`)
const response = await octokit.request("GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts?name={artifactName}", {
owner: github.context.repo.owner,
@@ -69,7 +67,27 @@ async function getArtifactMetadata({ githubToken, runId, artifactName }) {
artifactName: artifactName
})
return response.data
const artifactCount = response.data.total_count
core.debug(`List artifact count: ${artifactCount}`)
if (artifactCount === 0) {
throw new Error(`No artifacts found for workflow run ${runId}. Ensure artifacts are uploaded with actions/artifact@v4 or later.`)
} else if (artifactCount > 1) {
throw new Error(`Multiple artifact unexpectedly found for workflow run ${runId}. Artifact count is ${artifactCount}.`)
}
const artifact = response.data.artifacts[0]
core.debug(`Artifact: ${JSON.stringify(artifact)}`)
const artifactSize = artifact.size_in_bytes
if (!artifactSize) {
core.warning('Artifact size was not found. Unable to verify if artifact size exceeds the allowed size.')
}
return {
id: artifact.id,
size: artifactSize
}
} catch (error) {
core.error('Fetching artifact metadata failed', error)
throw error

View File

@@ -41,7 +41,7 @@ class Deployment {
this.startTime = null
}
// Ask the runtime for the unsigned artifact URL and deploy to GitHub Pages
// Ask the runtime for and artifact id and deploy to GitHub Pages
// by creating a deployment with that artifact
async create(idToken) {
if (Number(core.getInput('timeout')) > MAX_TIMEOUT) {
@@ -67,6 +67,8 @@ class Deployment {
console.log(artifactData)
// TODO create deployment
return
} catch (error) {
core.error(error.stack)