managed to execute docker hub push and execute that image

This commit is contained in:
Nikola Jokic
2022-10-24 13:13:16 +02:00
parent e33f331739
commit 7271e71008
2 changed files with 15 additions and 7 deletions

View File

@@ -24,7 +24,8 @@ import {
localRegistryPort,
remoteRegistryHost,
remoteRegistryHandle,
remoteRegistrySecretName
remoteRegistrySecretName,
isLocalRegistrySet
} from './settings'
export * from './settings'
@@ -486,14 +487,19 @@ export async function containerBuild(
let kanikoRegistry = ''
let pullRegistry = ''
let secretName: string | undefined = undefined
if (localRegistryHost()) {
if (isLocalRegistrySet()) {
const host = `${localRegistryHost()}.${namespace()}.svc.cluster.local`
const port = localRegistryPort()
const uri = `${generateBuildHandle()}/${generateBuildImage()}`
kanikoRegistry = `${host}:${port}/${uri}`
pullRegistry = `localhost:${localRegistryNodePort()}/${uri}`
} else {
kanikoRegistry = `${remoteRegistryHost()}/${remoteRegistryHandle()}/${generateBuildImage()}`
const uri = `${remoteRegistryHandle()}/${generateBuildImage()}`
if (remoteRegistryHost()) {
kanikoRegistry = `${remoteRegistryHost()}/${uri}`
} else {
kanikoRegistry = uri
}
pullRegistry = kanikoRegistry
secretName = remoteRegistrySecretName()
}

View File

@@ -22,6 +22,11 @@ export function namespace(): string {
return context.namespace
}
export function isLocalRegistrySet(): boolean {
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST'
return !!process.env[name]
}
export function localRegistryHost(): string {
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_LOCAL_REGISTRY_HOST'
if (process.env[name]) {
@@ -48,10 +53,7 @@ export function localRegistryNodePort(): number {
export function remoteRegistryHost(): string {
const name = 'ACTIONS_RUNNER_CONTAINER_HOOKS_REMOTE_REGISTRY_HOST'
if (process.env[name]) {
return process.env[name]
}
throw new Error(`environment variable ${name} is not set`)
return process.env[name] || ''
}
export function remoteRegistryHandle(): string {