Skip to content

Commit 5d06edc

Browse files
committed
Moved changes to context module, added check to prevent overriding user input
1 parent be3385a commit 5d06edc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/context.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export function tmpNameSync(options?: tmp.TmpNameOptions): string {
5454
}
5555

5656
export async function getInputs(defaultContext: string): Promise<Inputs> {
57-
return {
57+
58+
let userInputs = {
5859
context: core.getInput('context') || defaultContext,
5960
file: core.getInput('file') || 'Dockerfile',
6061
buildArgs: await getInputList('build-args', true),
@@ -75,6 +76,20 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
7576
githubToken: core.getInput('github-token'),
7677
ssh: await getInputList('ssh')
7778
};
79+
80+
//Add repo as source-label if not already supplied by user
81+
const sourceLabelKey = 'org.opencontainers.image.source';
82+
if( userInputs.labels.find(val => val.startsWith(sourceLabelKey) == true ) == null){
83+
userInputs.labels.push(
84+
`${sourceLabelKey}=https://github.com/${github.context.repo.owner}/${github.context.repo.repo}`
85+
);
86+
}
87+
88+
//Add dockerfile path as label
89+
let dockerfilePath = userInputs.file;
90+
userInputs.labels.push(`dockerfile-path=${dockerfilePath}`);
91+
92+
return userInputs;
7893
}
7994

8095
export async function getArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {

0 commit comments

Comments
 (0)