mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-26 10:10:59 -05:00
Merge pull request #123 from sharesight/ssh-arg
Add support to pass `--ssh` flag to the build
This commit is contained in:
commit
2e36e439bc
4 changed files with 19 additions and 4 deletions
|
@ -673,6 +673,7 @@ Following inputs can be used as `step.with` keys
|
||||||
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `type=local,src=path/to/dir`) |
|
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `type=local,src=path/to/dir`) |
|
||||||
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `type=local,dest=path/to/dir`) |
|
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `type=local,dest=path/to/dir`) |
|
||||||
| `secrets` | List | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) |
|
| `secrets` | List | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) |
|
||||||
|
| `ssh` | List | List of SSH agent socket or keys to expose to the build (eg: `default|<id>[=<socket>|<key>[,<key>]]`) |
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@ inputs:
|
||||||
description: "GitHub Token used to authenticate against a repository for Git context"
|
description: "GitHub Token used to authenticate against a repository for Git context"
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
required: false
|
required: false
|
||||||
|
ssh:
|
||||||
|
description: "List of SSH agent socket or keys to expose to the build (eg: default)"
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
digest:
|
digest:
|
||||||
|
|
8
dist/index.js
generated
vendored
8
dist/index.js
generated
vendored
|
@ -12039,9 +12039,9 @@ const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const semver = __importStar(__webpack_require__(383));
|
const semver = __importStar(__webpack_require__(383));
|
||||||
const tmp = __importStar(__webpack_require__(517));
|
const tmp = __importStar(__webpack_require__(517));
|
||||||
const buildx = __importStar(__webpack_require__(295));
|
|
||||||
const core = __importStar(__webpack_require__(186));
|
const core = __importStar(__webpack_require__(186));
|
||||||
const github = __importStar(__webpack_require__(438));
|
const github = __importStar(__webpack_require__(438));
|
||||||
|
const buildx = __importStar(__webpack_require__(295));
|
||||||
let _defaultContext, _tmpDir;
|
let _defaultContext, _tmpDir;
|
||||||
function defaultContext() {
|
function defaultContext() {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
|
@ -12082,7 +12082,8 @@ function getInputs(defaultContext) {
|
||||||
cacheFrom: yield getInputList('cache-from', true),
|
cacheFrom: yield getInputList('cache-from', true),
|
||||||
cacheTo: yield getInputList('cache-to', true),
|
cacheTo: yield getInputList('cache-to', true),
|
||||||
secrets: yield getInputList('secrets', true),
|
secrets: yield getInputList('secrets', true),
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token'),
|
||||||
|
ssh: yield getInputList('ssh')
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -12137,6 +12138,9 @@ function getBuildArgs(inputs, defaultContext, buildxVersion) {
|
||||||
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
|
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
|
||||||
args.push('--secret', yield buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
args.push('--secret', yield buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
||||||
}
|
}
|
||||||
|
yield exports.asyncForEach(inputs.ssh, (ssh) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
args.push('--ssh', ssh);
|
||||||
|
}));
|
||||||
if (inputs.file) {
|
if (inputs.file) {
|
||||||
args.push('--file', inputs.file);
|
args.push('--file', inputs.file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,12 @@ import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
import * as buildx from './buildx';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as github from '@actions/github';
|
import * as github from '@actions/github';
|
||||||
|
|
||||||
|
import * as buildx from './buildx';
|
||||||
|
|
||||||
let _defaultContext, _tmpDir: string;
|
let _defaultContext, _tmpDir: string;
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
|
@ -28,6 +30,7 @@ export interface Inputs {
|
||||||
cacheTo: string[];
|
cacheTo: string[];
|
||||||
secrets: string[];
|
secrets: string[];
|
||||||
githubToken: string;
|
githubToken: string;
|
||||||
|
ssh: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function defaultContext(): string {
|
export function defaultContext(): string {
|
||||||
|
@ -69,7 +72,8 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
|
||||||
cacheFrom: await getInputList('cache-from', true),
|
cacheFrom: await getInputList('cache-from', true),
|
||||||
cacheTo: await getInputList('cache-to', true),
|
cacheTo: await getInputList('cache-to', true),
|
||||||
secrets: await getInputList('secrets', true),
|
secrets: await getInputList('secrets', true),
|
||||||
githubToken: core.getInput('github-token')
|
githubToken: core.getInput('github-token'),
|
||||||
|
ssh: await getInputList('ssh')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +126,9 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
|
||||||
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
|
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
|
||||||
args.push('--secret', await buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
args.push('--secret', await buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
|
||||||
}
|
}
|
||||||
|
await asyncForEach(inputs.ssh, async ssh => {
|
||||||
|
args.push('--ssh', ssh);
|
||||||
|
});
|
||||||
if (inputs.file) {
|
if (inputs.file) {
|
||||||
args.push('--file', inputs.file);
|
args.push('--file', inputs.file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue