Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .github/workflows/bake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ on:
description: "Cache layers to export if cache enabled (min or max)"
required: false
default: 'min'
repository:
type: string
description: "Git repository to use for Git context, in the format of owner/repo. (defaults to the current repository)"
required: false
default: ${{ github.repository }}
ref:
type: string
description: "Git ref to use for Git context. (defaults to the default branch of the repository)"
required: false
default: ${{ github.ref }}
context:
type: string
description: "Context to build from in the Git working tree"
Expand Down Expand Up @@ -163,7 +173,6 @@ env:
COSIGN_VERSION: "v3.0.2"
LOCAL_EXPORT_DIR: "/tmp/buildx-output"
MATRIX_SIZE_LIMIT: "20"
BUILDX_SEND_GIT_QUERY_AS_INPUT: "true"

jobs:
prepare:
Expand Down Expand Up @@ -254,6 +263,8 @@ jobs:
INPUT_RUNNER: ${{ inputs.runner }}
INPUT_DISTRIBUTE: ${{ inputs.distribute }}
INPUT_ARTIFACT-UPLOAD: ${{ inputs.artifact-upload }}
INPUT_REPOSITORY: ${{ inputs.repository }}
INPUT_REF: ${{ inputs.ref }}
INPUT_CONTEXT: ${{ inputs.context }}
INPUT_FILES: ${{ inputs.files }}
INPUT_OUTPUT: ${{ inputs.output }}
Expand All @@ -279,6 +290,8 @@ jobs:
const inpRunner = core.getInput('runner');
const inpDistribute = core.getBooleanInput('distribute');
const inpArtifactUpload = core.getBooleanInput('artifact-upload');
const inpRepository = core.getInput('repository');
const inpRef = core.getInput('ref');
const inpContext = core.getInput('context');
const inpVars = Util.getInputList('vars');
const inpFiles = Util.getInputList('files');
Expand Down Expand Up @@ -315,7 +328,7 @@ jobs:
return;
}

const bakeSource = await new Build().gitContext({subdir: inpContext});
const bakeSource = `${process.env.GITHUB_SERVER_URL}/${inpRepository}.git#${inpRef}:${inpContext}`;
await core.group(`Set bake source`, async () => {
core.info(bakeSource);
});
Expand Down Expand Up @@ -624,6 +637,8 @@ jobs:
INPUT_CACHE: ${{ inputs.cache }}
INPUT_CACHE-SCOPE: ${{ inputs.cache-scope }}
INPUT_CACHE-MODE: ${{ inputs.cache-mode }}
INPUT_REPOSITORY: ${{ inputs.repository }}
INPUT_REF: ${{ inputs.ref }}
INPUT_CONTEXT: ${{ inputs.context }}
INPUT_FILES: ${{ inputs.files }}
INPUT_OUTPUT: ${{ inputs.output }}
Expand Down Expand Up @@ -659,6 +674,8 @@ jobs:
const inpCache = core.getBooleanInput('cache');
const inpCacheScope = core.getInput('cache-scope');
const inpCacheMode = core.getInput('cache-mode');
const inpRepository = core.getInput('repository');
const inpRef = core.getInput('ref');
const inpContext = core.getInput('context');
const inpFiles = Util.getInputList('files');
const inpOutput = core.getInput('output');
Expand All @@ -683,7 +700,7 @@ jobs:
};
const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta});

const bakeSource = await new Build().gitContext({subdir: inpContext});
const bakeSource = `${process.env.GITHUB_SERVER_URL}/${inpRepository}.git#${inpRef}:${inpContext}`;
await core.group(`Set source output`, async () => {
core.info(bakeSource);
core.setOutput('source', bakeSource);
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ on:
description: "Cache layers to export if cache enabled (min or max)"
required: false
default: 'min'
repository:
type: string
description: "Git repository to use for Git context, in the format of owner/repo. (defaults to the current repository)"
required: false
default: ${{ github.repository }}
ref:
type: string
description: "Git ref to use for Git context. (defaults to the default branch of the repository)"
required: false
default: ${{ github.ref }}
context:
type: string
description: "Context to build from in the Git working tree"
Expand Down Expand Up @@ -166,7 +176,6 @@ env:
COSIGN_VERSION: "v3.0.2"
LOCAL_EXPORT_DIR: "/tmp/buildx-output"
MATRIX_SIZE_LIMIT: "20"
BUILDX_SEND_GIT_QUERY_AS_INPUT: "true"

jobs:
prepare:
Expand Down Expand Up @@ -520,6 +529,8 @@ jobs:
INPUT_CACHE-SCOPE: ${{ inputs.cache-scope }}
INPUT_CACHE-MODE: ${{ inputs.cache-mode }}
INPUT_LABELS: ${{ inputs.labels }}
INPUT_REPOSITORY: ${{ inputs.repository }}
INPUT_REF: ${{ inputs.ref }}
INPUT_CONTEXT: ${{ inputs.context }}
INPUT_OUTPUT: ${{ inputs.output }}
INPUT_PLATFORMS: ${{ inputs.platforms }}
Expand Down Expand Up @@ -552,6 +563,8 @@ jobs:
const inpCache = core.getBooleanInput('cache');
const inpCacheScope = core.getInput('cache-scope');
const inpCacheMode = core.getInput('cache-mode');
const inpRepository = core.getInput('repository');
const inpRef = core.getInput('ref');
const inpContext = core.getInput('context');
const inpLabels = core.getInput('labels');
const inpOutput = core.getInput('output');
Expand All @@ -576,7 +589,7 @@ jobs:
const renderTemplate = value => Handlebars.compile(value, {noEscape: true})({meta});
const toMultilineInput = value => value.split(/\r?\n/).map(line => line.trim()).filter(Boolean);

const buildContext = await new Build().gitContext({subdir: inpContext});
const buildContext = `${process.env.GITHUB_SERVER_URL}/${inpRepository}.git#${inpRef}:${inpContext}`;
core.setOutput('context', buildContext);

switch (inpOutput) {
Expand Down