mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-19 03:16:44 +00:00
random handle and random image name
This commit is contained in:
@@ -19,13 +19,13 @@ import {
|
|||||||
PodPhase,
|
PodPhase,
|
||||||
writeEntryPointScript
|
writeEntryPointScript
|
||||||
} from '../k8s/utils'
|
} from '../k8s/utils'
|
||||||
import { getRunnerPodName, JOB_CONTAINER_NAME } from './constants'
|
import { JOB_CONTAINER_NAME } from './constants'
|
||||||
|
|
||||||
export async function runContainerStep(
|
export async function runContainerStep(
|
||||||
stepContainer: RunContainerStepArgs
|
stepContainer: RunContainerStepArgs
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
if (stepContainer.dockerfile) {
|
if (stepContainer.dockerfile) {
|
||||||
const imagePath = `${generateRandomHandle()}/${generateBuildTag()}`
|
const imagePath = `${generateBuildHandle()}/${generateBuildTag()}`
|
||||||
await containerBuild(stepContainer, imagePath)
|
await containerBuild(stepContainer, imagePath)
|
||||||
throw new Error('Building container actions is not currently supported')
|
throw new Error('Building container actions is not currently supported')
|
||||||
}
|
}
|
||||||
@@ -114,14 +114,18 @@ function createPodSpec(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateBuildTag(): string {
|
function generateBuildTag(): string {
|
||||||
return `${getRunnerPodName}:${uuidv4().substring(0, 6)}`
|
return `${generateRandomString()}:${uuidv4().substring(0, 6)}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateRandomHandle(length = 10): string {
|
function generateBuildHandle(): string {
|
||||||
let handle = ''
|
return generateRandomString()
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateRandomString(length = 10): string {
|
||||||
|
let v = ''
|
||||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
handle += chars.charAt(Math.floor(Math.random() * length))
|
v += chars.charAt(Math.floor(Math.random() * length))
|
||||||
}
|
}
|
||||||
return handle
|
return v
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user