Compare commits

..

6 Commits

Author SHA1 Message Date
c84f382811 Merge pull request #663 from crazy-max/fix-git-token-cond
Fix GitHub token not passed with Git context if subdir defined
2022-08-03 17:25:08 +02:00
cd5d0b79ea Merge pull request #661 from dud225/subdir_context
Update comment regarding the support of subdir context
2022-08-03 16:59:34 +02:00
30a32246ba Fix GitHub token not passed with Git context if subdir defined
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-08-03 14:39:01 +02:00
1f19633b92 Update comment regarding the support of subdir context
Signed-off-by: Hervé Werner <dud225@hotmail.com>
2022-08-03 13:55:05 +02:00
67af6dc1d3 Merge pull request #657 from bendrucker/deprecated-fs-rmdir
Replace deprecated `fs.rmdir` with `fs.rm`
2022-07-28 11:04:08 +02:00
988cb093f2 replace deprecated fs.rmdir with fs.rm
Signed-off-by: Ben Drucker <bvdrucker@gmail.com>
2022-07-27 16:47:22 -07:00
6 changed files with 28 additions and 8 deletions

View File

@ -108,7 +108,7 @@ to the default Git context:
push: true
tags: user/app:latest
```
> :warning: Subdirectory for Git context is not yet available for the buildx [`docker` driver](https://github.com/docker/buildx/blob/master/docs/reference/buildx_create.md#driver).
> :warning: Subdirectory for Git context is only available from [Buildkit version 0.9.0](https://github.com/moby/buildkit/releases/tag/v0.9.0).
Building from the current repository automatically uses the [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)
so it does not need to be passed. If you want to authenticate against another

View File

@ -500,6 +500,25 @@ nproc=3`],
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:docker'
]
],
[
16,
'0.8.2',
new Map<string, string>([
['github-token', 'abcdefghijklmno0123456789'],
['context', '{{defaultContext}}:subdir'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false'],
]),
[
'build',
'--iidfile', '/tmp/.docker-build-push-jest/iidfile',
'--secret', 'id=GIT_AUTH_TOKEN,src=/tmp/.docker-build-push-jest/.tmpname-jest',
'--metadata-file', '/tmp/.docker-build-push-jest/metadata-file',
'https://github.com/docker/build-push-action.git#refs/heads/test-jest:subdir'
]
]
])(
'[%d] given %p with %p as inputs, returns %p',
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -101,15 +101,16 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
}
export async function getArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
const context = handlebars.compile(inputs.context)({defaultContext});
// prettier-ignore
return [
...await getBuildArgs(inputs, defaultContext, buildxVersion),
...await getBuildArgs(inputs, defaultContext, context, buildxVersion),
...await getCommonArgs(inputs, buildxVersion),
handlebars.compile(inputs.context)({defaultContext})
context
];
}
async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersion: string): Promise<Array<string>> {
async function getBuildArgs(inputs: Inputs, defaultContext: string, context: string, buildxVersion: string): Promise<Array<string>> {
const args: Array<string> = ['build'];
await asyncForEach(inputs.addHosts, async addHost => {
args.push('--add-host', addHost);
@ -166,7 +167,7 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
core.warning(err.message);
}
});
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && context.startsWith(defaultContext)) {
args.push('--secret', await buildx.getSecretString(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
}
if (inputs.shmSize) {

View File

@ -83,7 +83,7 @@ async function run(): Promise<void> {
async function cleanup(): Promise<void> {
if (stateHelper.tmpDir.length > 0) {
core.startGroup(`Removing temp folder ${stateHelper.tmpDir}`);
fs.rmdirSync(stateHelper.tmpDir, {recursive: true});
fs.rmSync(stateHelper.tmpDir, {recursive: true});
core.endGroup();
}
}