fix registry auth string being suffixed with "/owner/repo:", dynamically determine .docker/config.json, renamed targetRegistries to targetRepos to better clarify content (list of "registry/owner/repo:prefix-" and not actual registries)

This commit is contained in:
2023-12-06 12:15:14 +01:00
parent f92a7c85b3
commit 6c5883876a
4 changed files with 63 additions and 14 deletions
+30 -7
View File
@@ -62097,6 +62097,8 @@ const gBase64 = {
// and finally,
// EXTERNAL MODULE: external "os"
var external_os_ = __nccwpck_require__(2037);
// EXTERNAL MODULE: external "path"
var external_path_ = __nccwpck_require__(1017);
;// CONCATENATED MODULE: ./src/lib.js
@@ -62107,6 +62109,7 @@ var external_path_ = __nccwpck_require__(1017);
function processAdditionalRegistries(targetRegistries) {
const additionalRegistries = core.getInput('additional_registries');
if (additionalRegistries != null && additionalRegistries.length > 0) {
@@ -62359,6 +62362,20 @@ function executeDockerBuild(dockerArgs, destinations) {
}
}
function determineDockerConfigFileLocation(path) {
if (path == null || !path.length) {
return external_os_.homedir + '/.docker/config.json';
}
// absolute path
if (path.startsWith('/')) {
return path;
}
// relative path to home dir
return external_os_.homedir + '/' + path;
}
function lib_isTrueString(str) {
return str === '1'
|| str === 'true'
@@ -62382,27 +62399,33 @@ try {
const debug = lib_isTrueString(process.env['ACTIONS_STEP_DEBUG']);
let targetRegistries = [];
const repoStr = github.context.repo.owner + '/' + github.context.repo.repo;
let targetRepos = [];
const repoStr = github.context.repo.owner + '/' + github.context.repo.repo;
let ci_registry = false;
if (core.getBooleanInput('add_ci_registry_target')) {
ci_registry = information.ci_hostname + '/' + repoStr + ':';
targetRegistries.push(ci_registry);
const ci_registry_repo = information.ci_hostname + '/' + repoStr + ':';
targetRepos.push(ci_registry_repo);
}
processAdditionalRegistries(targetRepos);
const dockerConfigFile = determineDockerConfigFileLocation(core.getInput('docker_auth_json_file'));
if (debug) {
console.log('determined .docker/config.json location: ', dockerConfigFile);
}
processAdditionalRegistries(targetRegistries);
const registryAuthJson = {auths: {}};
addCiRegistryAuth(ci_registry, registryAuthJson);
mergeArgRegistryAuthJson(registryAuthJson);
writeRegistryAuthJson(registryAuthJson, '/home/runner/.docker/config.json');
writeRegistryAuthJson(registryAuthJson, dockerConfigFile);
const tags = collectTags(information);
if (debug) {
console.log('tags:', JSON.stringify(tags, null, 2));
}
const destinations = prepareDestinations(targetRegistries, tags);
const destinations = prepareDestinations(targetRepos, tags);
if (debug || core.getBooleanInput('debug_log_destinations')) {
console.log('destinations:', JSON.stringify(destinations, null, 2));
}