1
0
Fork 0
mirror of https://github.com/docker/build-push-action.git synced 2025-03-30 19:50:07 +02:00

Fixed link to dockerfile

Signed-off-by: Jyotsna <Josh-01@github.com>
This commit is contained in:
Jyotsna 2020-11-11 21:07:49 +05:30
parent 065688b98f
commit c59c0cec43
3 changed files with 50 additions and 15 deletions

View file

@ -147,8 +147,31 @@ describe('getArgs', () => {
[
'buildx',
'build',
'--label', 'org.opencontainers.image.source=https://github.com/docker/build-push-action.git',
'--label', 'dockerfile-path=./test/Dockerfile',
'--platform', 'linux/amd64,linux/arm64',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
'--file', './test/Dockerfile',
'--builder', 'builder-git-context-2',
'--push',
'https://github.com/docker/build-push-action.git#heads/master'
]
],
[
'0.4.2',
new Map<string, string>([
['context', 'https://github.com/docker/build-push-action.git#heads/master'],
['tag', 'localhost:5000/name/app:latest'],
['platforms', 'linux/amd64,linux/arm64'],
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
['file', './test/Dockerfile'],
['builder', 'builder-git-context-2'],
['push', 'true'],
['trace-data', 'true']
]),
[
'buildx',
'build',
'--label', 'dockerfile-path=https://github.com/docker/build-push-action.git#test-jest/./test/Dockerfile',
'--platform', 'linux/amd64,linux/arm64',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
@ -162,14 +185,13 @@ describe('getArgs', () => {
'0.4.2',
new Map<string, string>([
['context', '.'],
['labels', 'org.opencontainers.image.source=UserProvidedSourceLabel'],
['outputs', 'type=image,dest=./release-out']
['outputs', 'type=image,dest=./release-out'],
['trace-data', 'true']
]),
[
'buildx',
'build',
'--label', 'org.opencontainers.image.source=UserProvidedSourceLabel',
'--label', 'dockerfile-path=Dockerfile',
'--label', 'dockerfile-path=https://github.com/docker/build-push-action.git#test-jest/Dockerfile',
'--output', 'type=image,dest=./release-out',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--file', 'Dockerfile',
@ -180,13 +202,13 @@ describe('getArgs', () => {
'0.4.2',
new Map<string, string>([
['context', '.'],
['outputs', 'type=registry,dest=./release-out']
['outputs', 'type=registry,dest=./release-out'],
['trace-data', 'true']
]),
[
'buildx',
'build',
'--label', 'org.opencontainers.image.source=https://github.com/docker/build-push-action.git',
'--label', 'dockerfile-path=Dockerfile',
'--label', 'dockerfile-path=https://github.com/docker/build-push-action.git#test-jest/Dockerfile',
'--output', 'type=registry,dest=./release-out',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--file', 'Dockerfile',
@ -197,14 +219,13 @@ describe('getArgs', () => {
'0.4.2',
new Map<string, string>([
['context', '.'],
['labels', 'org.opencontainers.image.source=UserProvidedSourceLabel'],
['load', 'true']
['load', 'true'],
['trace-data', 'true']
]),
[
'buildx',
'build',
'--label', 'org.opencontainers.image.source=UserProvidedSourceLabel',
'--label', 'dockerfile-path=Dockerfile',
'--label', 'dockerfile-path=https://github.com/docker/build-push-action.git#test-jest/Dockerfile',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--file', 'Dockerfile',
'--load',

9
dist/index.js generated vendored
View file

@ -12092,7 +12092,14 @@ function getInputs(defaultContext) {
userInputs.outputs.find(val => val.indexOf('type=image') > -1 || val.indexOf('type=registry') > -1))) {
//Add link to dockerfile as label
let dockerfilePath = userInputs.file;
let repoPath = defaultContext.replace('#head', '/blob');
let stringToReplace = '';
if (defaultContext.indexOf('#heads')) {
stringToReplace = '.git#heads';
}
else if (defaultContext.indexOf('#tags')) {
stringToReplace = '.git#tags';
}
let repoPath = defaultContext.replace(stringToReplace, '/blob');
userInputs.labels.push(`dockerfile-path=${repoPath}/${dockerfilePath}`);
}
return userInputs;

View file

@ -85,7 +85,14 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
) {
//Add link to dockerfile as label
let dockerfilePath = userInputs.file;
let repoPath = defaultContext.replace('#head', '/blob');
let stringToReplace = '';
if (defaultContext.indexOf('#heads')) {
stringToReplace = '.git#heads';
} else if (defaultContext.indexOf('#tags')) {
stringToReplace = '.git#tags';
}
let repoPath = defaultContext.replace(stringToReplace, '/blob');
userInputs.labels.push(`dockerfile-path=${repoPath}/${dockerfilePath}`);
}