use local dockerfile path over git context (#86)

This commit is contained in:
Aayush Shah 2024-12-31 13:08:49 -05:00 committed by GitHub
parent 8e7197156e
commit c03b613806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 9 deletions

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -89,18 +89,17 @@ export async function getInputs(): Promise<Inputs> {
export function getDockerfilePath(inputs: Inputs): string | null {
try {
const context = inputs.context || Context.gitContext();
const normalizedContext = path.normalize(context);
let dockerfilePath: string;
if (inputs.file) {
const normalizedFile = path.normalize(inputs.file);
dockerfilePath = normalizedFile.startsWith(normalizedContext) ? normalizedFile : path.join(normalizedContext, normalizedFile);
// If context is git context, just use the file path directly
dockerfilePath = context === Context.gitContext() ? inputs.file : path.join(path.normalize(context), inputs.file);
} else if (inputs['dockerfile']) {
const normalizedDockerfile = path.normalize(inputs['dockerfile']);
dockerfilePath = normalizedDockerfile.startsWith(normalizedContext) ? normalizedDockerfile : path.join(normalizedContext, normalizedDockerfile);
// If context is git context, just use the dockerfile path directly
dockerfilePath = context === Context.gitContext() ? inputs['dockerfile'] : path.join(path.normalize(context), inputs['dockerfile']);
} else {
// Default to Dockerfile in the context directory
dockerfilePath = path.join(normalizedContext, 'Dockerfile');
// If context is git context, just use 'Dockerfile'
dockerfilePath = context === Context.gitContext() ? 'Dockerfile' : path.join(path.normalize(context), 'Dockerfile');
}
// Verify the file exists