Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use local dockerfile path over git context #86

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -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