mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-19 03:16:44 +00:00
managed to execute docker hub push and execute that image
This commit is contained in:
@@ -24,7 +24,8 @@ import {
|
|||||||
localRegistryPort,
|
localRegistryPort,
|
||||||
remoteRegistryHost,
|
remoteRegistryHost,
|
||||||
remoteRegistryHandle,
|
remoteRegistryHandle,
|
||||||
remoteRegistrySecretName
|
remoteRegistrySecretName,
|
||||||
|
isLocalRegistrySet
|
||||||
} from './settings'
|
} from './settings'
|
||||||
|
|
||||||
export * from './settings'
|
export * from './settings'
|
||||||
@@ -486,14 +487,19 @@ export async function containerBuild(
|
|||||||
let kanikoRegistry = ''
|
let kanikoRegistry = ''
|
||||||
let pullRegistry = ''
|
let pullRegistry = ''
|
||||||
let secretName: string | undefined = undefined
|
let secretName: string | undefined = undefined
|
||||||
if (localRegistryHost()) {
|
if (isLocalRegistrySet()) {
|
||||||
const host = `${localRegistryHost()}.${namespace()}.svc.cluster.local`
|
const host = `${localRegistryHost()}.${namespace()}.svc.cluster.local`
|
||||||
const port = localRegistryPort()
|
const port = localRegistryPort()
|
||||||
const uri = `${generateBuildHandle()}/${generateBuildImage()}`
|
const uri = `${generateBuildHandle()}/${generateBuildImage()}`
|
||||||
kanikoRegistry = `${host}:${port}/${uri}`
|
kanikoRegistry = `${host}:${port}/${uri}`
|
||||||
pullRegistry = `localhost:${localRegistryNodePort()}/${uri}`
|
pullRegistry = `localhost:${localRegistryNodePort()}/${uri}`
|
||||||
} else {
|
} else {
|
||||||
kanikoRegistry = `${remoteRegistryHost()}/${remoteRegistryHandle()}/${generateBuildImage()}`
|
const uri = `${remoteRegistryHandle()}/${generateBuildImage()}`
|
||||||
|
if (remoteRegistryHost()) {
|
||||||
|
kanikoRegistry = `${remoteRegistryHost()}/${uri}`
|
||||||
|
} else {
|
||||||
|
kanikoRegistry = uri
|
||||||
|
}
|
||||||
pullRegistry = kanikoRegistry
|
pullRegistry = kanikoRegistry
|
||||||
secretName = remoteRegistrySecretName()
|
secretName = remoteRegistrySecretName()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ export function namespace(): string {
|
|||||||
return context.namespace
|
return context.namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isLocalRegistrySet(): boolean {
|
||||||
|
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST'
|
||||||
|
return !!process.env[name]
|
||||||
|
}
|
||||||
|
|
||||||
export function localRegistryHost(): string {
|
export function localRegistryHost(): string {
|
||||||
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST'
|
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST'
|
||||||
if (process.env[name]) {
|
if (process.env[name]) {
|
||||||
@@ -48,10 +53,7 @@ export function localRegistryNodePort(): number {
|
|||||||
|
|
||||||
export function remoteRegistryHost(): string {
|
export function remoteRegistryHost(): string {
|
||||||
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_REMOTE_REGISTRY_HOST'
|
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_REMOTE_REGISTRY_HOST'
|
||||||
if (process.env[name]) {
|
return process.env[name] || ''
|
||||||
return process.env[name]
|
|
||||||
}
|
|
||||||
throw new Error(`environment variable ${name} is not set`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function remoteRegistryHandle(): string {
|
export function remoteRegistryHandle(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user