mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-19 01:46:45 +00:00
Check context type
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
10b9d7ec22
commit
9c473659de
6 changed files with 835 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
import gitUrlParse from 'git-url-parse';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
export interface Inputs {
|
||||
|
@ -24,7 +25,7 @@ export interface Inputs {
|
|||
|
||||
export async function getInputs(): Promise<Inputs> {
|
||||
return {
|
||||
context: core.getInput('context') || '.',
|
||||
context: await getBuildContext(),
|
||||
file: core.getInput('file') || './Dockerfile',
|
||||
buildArgs: await getInputList('build-args'),
|
||||
labels: await getInputList('labels'),
|
||||
|
@ -65,6 +66,21 @@ 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);
|
||||
gitURL.token = gitURL.token || process.env['GIT_TOKEN'] || process.env['GITHUB_TOKEN'] || '';
|
||||
gitURL.ref = gitURL.ref || process.env['GIT_REF'] || process.env['GITHUB_REF'] || '';
|
||||
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