Skip to content

Commit 2e36e43

Browse files
authored
Merge pull request #123 from sharesight/ssh-arg
Add support to pass `--ssh` flag to the build
2 parents 41a0040 + 6e7bd99 commit 2e36e43

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ Following inputs can be used as `step.with` keys
673673
| `cache-from` | List | List of [external cache sources](https://github.com/docker/buildx#--cache-fromnametypetypekeyvalue) (eg. `type=local,src=path/to/dir`) |
674674
| `cache-to` | List | List of [cache export destinations](https://github.com/docker/buildx#--cache-tonametypetypekeyvalue) (eg. `type=local,dest=path/to/dir`) |
675675
| `secrets` | List | List of secrets to expose to the build (eg. `key=value`, `GIT_AUTH_TOKEN=mytoken`) |
676+
| `ssh` | List | List of SSH agent socket or keys to expose to the build (eg: `default|<id>[=<socket>|<key>[,<key>]]`) |
676677

677678
### outputs
678679

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ inputs:
6767
description: "GitHub Token used to authenticate against a repository for Git context"
6868
default: ${{ github.token }}
6969
required: false
70+
ssh:
71+
description: "List of SSH agent socket or keys to expose to the build (eg: default)"
72+
required: false
7073

7174
outputs:
7275
digest:

dist/index.js

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import * as os from 'os';
33
import * as path from 'path';
44
import * as semver from 'semver';
55
import * as tmp from 'tmp';
6-
import * as buildx from './buildx';
6+
77
import * as core from '@actions/core';
88
import * as github from '@actions/github';
99

10+
import * as buildx from './buildx';
11+
1012
let _defaultContext, _tmpDir: string;
1113

1214
export interface Inputs {
@@ -28,6 +30,7 @@ export interface Inputs {
2830
cacheTo: string[];
2931
secrets: string[];
3032
githubToken: string;
33+
ssh: string[];
3134
}
3235

3336
export function defaultContext(): string {
@@ -69,7 +72,8 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
6972
cacheFrom: await getInputList('cache-from', true),
7073
cacheTo: await getInputList('cache-to', true),
7174
secrets: await getInputList('secrets', true),
72-
githubToken: core.getInput('github-token')
75+
githubToken: core.getInput('github-token'),
76+
ssh: await getInputList('ssh')
7377
};
7478
}
7579

@@ -122,6 +126,9 @@ async function getBuildArgs(inputs: Inputs, defaultContext: string, buildxVersio
122126
if (inputs.githubToken && !buildx.hasGitAuthToken(inputs.secrets) && inputs.context == defaultContext) {
123127
args.push('--secret', await buildx.getSecret(`GIT_AUTH_TOKEN=${inputs.githubToken}`));
124128
}
129+
await asyncForEach(inputs.ssh, async ssh => {
130+
args.push('--ssh', ssh);
131+
});
125132
if (inputs.file) {
126133
args.push('--file', inputs.file);
127134
}

0 commit comments

Comments
 (0)