Use url fragment for git ref context

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2020-08-17 17:31:15 +02:00
parent 8413351ed4
commit e7964906a6
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
5 changed files with 5 additions and 83 deletions

View file

@ -1,4 +1,3 @@
import gitUrlParse from 'git-url-parse';
import * as core from '@actions/core';
export interface Inputs {
@ -26,7 +25,7 @@ export interface Inputs {
export async function getInputs(): Promise<Inputs> {
return {
context: await getBuildContext(),
context: core.getInput('context') || '.',
file: core.getInput('file') || './Dockerfile',
buildArgs: await getInputList('build-args'),
labels: await getInputList('labels'),
@ -68,23 +67,6 @@ export async function getArgs(inputs: Inputs): Promise<Array<string>> {
return args;
}
async function getBuildContext(): Promise<string> {
let context: string = core.getInput('context');
if (!context) {
return '.';
}
try {
const gitUrl = gitUrlParse(context);
const gitRef = process.env['GIT_REF'] || '';
if (gitRef) {
return `${gitUrl.toString()}#${gitRef}`;
}
return gitUrl.toString();
} catch {
return context;
}
}
async function getCommonArgs(inputs: Inputs): Promise<Array<string>> {
let args: Array<string> = [];
if (inputs.noCache) {