Skip to content

Commit

Permalink
Don't fail on missing ~/.docker dir
Browse files Browse the repository at this point in the history
This is a follow-up to 8828a23 / redhat-actions#39
  • Loading branch information
PhrozenByte committed Aug 7, 2024
1 parent 4934294 commit 913e9b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { Inputs } from "./generated/inputs-outputs";

let podmanPath: string | undefined;
let registry: string;
const dockerConfigPath = path.join(os.homedir(), ".docker", "config.json");
const dockerConfigDir = path.join(os.homedir(), ".docker");
const dockerConfigPath = path.join(dockerConfigDir, "config.json");

async function getPodmanPath(): Promise<string> {
if (podmanPath == null) {
Expand Down Expand Up @@ -91,7 +92,8 @@ async function run(): Promise<void> {

dockerConfig.auths[registry] = generatedAuth;

await fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8");
await fs.mkdir(dockerConfigDir, { recursive: true })
.then(() => fs.writeFile(dockerConfigPath, JSON.stringify(dockerConfig, undefined, 8), "utf-8"));
}

async function registryLogout(): Promise<void> {
Expand Down

0 comments on commit 913e9b2

Please sign in to comment.