This commit is contained in:
Konrad Pabjan
2023-10-27 16:19:24 -04:00
parent 08232476b8
commit 38d3e68bdc
3 changed files with 26 additions and 38 deletions

59
dist/index.js generated vendored
View File

@@ -9865,6 +9865,24 @@ async function processRuntimeResponse(res, requestOptions) {
return response
}
async function getArtifactMetadata({githubToken, runId, artifactName}) {
const octokit = github.getOctokit(githubToken)
try {
const response = await octokit.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts?name={artifactName}', {
owner: github.context.repo.owner,
repo: github.context.repo.repo,
run_id: runId,
artifactName: artifactName
})
return response.data
} catch (error) {
core.error('Fetching artifact metadata failed', error)
throw error
}
}
async function getSignedArtifactMetadata({ runtimeToken, workflowRunId, artifactName }) {
const { runTimeUrl: RUNTIME_URL } = getContext()
const artifactExchangeUrl = `${RUNTIME_URL}_apis/pipelines/workflows/${workflowRunId}/artifacts?api-version=6.0-preview`
@@ -9984,6 +10002,7 @@ async function cancelPagesDeployment({ githubToken, deploymentId }) {
}
module.exports = {
getArtifactMetadata,
getSignedArtifactMetadata,
createPagesDeployment,
getPagesDeploymentStatus,
@@ -10001,9 +10020,7 @@ const core = __nccwpck_require__(2186)
// Load variables from Actions runtime
function getRequiredVars() {
return {
runTimeUrl: process.env.ACTIONS_RUNTIME_URL,
workflowRun: process.env.GITHUB_RUN_ID,
runTimeToken: process.env.ACTIONS_RUNTIME_TOKEN,
repositoryNwo: process.env.GITHUB_REPOSITORY,
buildVersion: process.env.GITHUB_SHA,
buildActor: process.env.GITHUB_ACTOR,
@@ -10038,8 +10055,7 @@ const core = __nccwpck_require__(2186)
// All variables we need from the runtime are loaded here
const getContext = __nccwpck_require__(8454)
const {
getSignedArtifactMetadata,
createPagesDeployment,
getArtifactMetadata,
getPagesDeploymentStatus,
cancelPagesDeployment
} = __nccwpck_require__(572)
@@ -10066,9 +10082,7 @@ const SIZE_LIMIT_DESCRIPTION = '1 GB'
class Deployment {
constructor() {
const context = getContext()
this.runTimeUrl = context.runTimeUrl
this.repositoryNwo = context.repositoryNwo
this.runTimeToken = context.runTimeToken
this.buildVersion = context.buildVersion
this.buildActor = context.buildActor
this.actionsId = context.actionsId
@@ -10100,40 +10114,15 @@ class Deployment {
core.debug(`Action ID: ${this.actionsId}`)
core.debug(`Actions Workflow Run ID: ${this.workflowRun}`)
const artifactData = await getSignedArtifactMetadata({
runtimeToken: this.runTimeToken,
const artifactData = await getArtifactMetadata({
githubToken: this.githubToken,
workflowRunId: this.workflowRun,
artifactName: this.artifactName
})
if (artifactData?.size > ONE_GIGABYTE) {
core.warning(
`Uploaded artifact size of ${artifactData?.size} bytes exceeds the allowed size of ${SIZE_LIMIT_DESCRIPTION}. Deployment might fail.`
)
}
console.log(artifactData)
const deployment = await createPagesDeployment({
githubToken: this.githubToken,
artifactUrl: artifactData.url,
buildVersion: this.buildVersion,
idToken,
isPreview: this.isPreview
})
if (deployment) {
this.deploymentInfo = {
...deployment,
id: deployment.id || deployment.status_url?.split('/')?.pop() || this.buildVersion,
pending: true
}
this.startTime = Date.now()
}
core.info(`Created deployment for ${this.buildVersion}, ID: ${this.deploymentInfo?.id}`)
core.debug(JSON.stringify(deployment))
return 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

@@ -4,7 +4,6 @@ const core = require('@actions/core')
const getContext = require('./context')
const {
getArtifactMetadata,
createPagesDeployment,
getPagesDeploymentStatus,
cancelPagesDeployment
} = require('./api-client')
@@ -71,7 +70,7 @@ class Deployment {
console.log(artifactData)
return nil
return
} catch (error) {
core.error(error.stack)