mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-20 10:26:44 +00:00
Use url fragment for git ref context
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
8413351ed4
commit
e7964906a6
5 changed files with 5 additions and 83 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue