-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add subdirectory for Git context #531
Add subdirectory for Git context #531
Conversation
src/context.ts
Outdated
@@ -97,7 +97,11 @@ export async function getArgs(inputs: Inputs, defaultContext: string, buildxVers | |||
let args: Array<string> = ['buildx']; | |||
args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion)); | |||
args.push.apply(args, await getCommonArgs(inputs, buildxVersion)); | |||
if (inputs.context.startsWith('{{defaultContext}}') && buildx.satisfies(buildxVersion, '>=0.7.0')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I add any type of error-handling here?
As it stands, if the version is <0.7.0 it's going to set the context to (literal) {{defaultContext}}:docker
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have to check buildx version here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the version of build-push-action is tied to the BuildX version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because it only affects buildkit not buildx. Also we need to vendor buildkit on moby moby/moby#42968 otherwise it will not work with the docker driver.
8f6d7e3
to
3dbe9f9
Compare
Locally, => ERROR [build-validate build-validate 1/1] RUN --mount=type=bind,target=.,rw <<EOT (set -e...) 0.5s
------
> [build-validate build-validate 1/1] RUN --mount=type=bind,target=.,rw <<EOT (set -e...):
#25 0.383 ERROR: Build result differs. Please build first with "docker buildx bake build"
#25 0.390 M dist/index.js
------
error: failed to solve: executor failed running [/bin/sh -c set -e
git add -A
cp -rf /out/* .
if [ -n "$(git status --porcelain -- dist)" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
git status --porcelain -- dist
exit 1
fi
]: exit code: 1
|
3dbe9f9
to
bc719c4
Compare
src/context.ts
Outdated
@@ -97,7 +97,11 @@ export async function getArgs(inputs: Inputs, defaultContext: string, buildxVers | |||
let args: Array<string> = ['buildx']; | |||
args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion)); | |||
args.push.apply(args, await getCommonArgs(inputs, buildxVersion)); | |||
if (inputs.context.startsWith('{{defaultContext}}') && buildx.satisfies(buildxVersion, '>=0.7.0')) { | |||
inputs.context = inputs.context.replace('{{defaultContext}}', defaultContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to use handlebars template like it was done in our metadata action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated @crazy-max 👍
64af63c
to
6cd5c4d
Compare
README.md
Outdated
@@ -43,6 +43,19 @@ By default, this action uses the [Git context](#git-context) so you don't need t | |||
done directly by buildkit. The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/reference/events-that-trigger-workflows) | |||
and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`. | |||
|
|||
Beginning with BuildKit version `v0.9.0` ([Buildx](https://github.com/docker/buildx) `v0.7.0`) you can provide a subdirectory to the [Git context](#git-context) by using the magic variable `{{defaultContext}}`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I replace magic variable
with handlebar template
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you can write smth like https://github.com/docker/metadata-action#global-expressions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated @crazy-max 👍
Since v0.9.0 of BuildKit (BuildX v0.7.0) you can provide a subdirectory to the default Git context. Closes docker#460 Closes docker#528 Signed-off-by: Jim Brännlund <[email protected]>
16858fe
to
fc5a732
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Since v0.9.0 of BuildKit (BuildX v0.7.0) you can provide a subdirectory
to the default Git context.
Closes #460
Closes #528