Skip to content

Commit efe9e38

Browse files
authored
Merge pull request #182 from crazy-max/releases-gh-token
set github token to list releases and download assets
2 parents 78e4df2 + 9321b68 commit efe9e38

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

__tests__/context.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('getInputs', () => {
3434
rootless: false,
3535
setHost: false,
3636
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
37+
githubToken: '',
3738
} as context.Inputs
3839
],
3940
[
@@ -57,6 +58,7 @@ describe('getInputs', () => {
5758
rootless: false,
5859
setHost: false,
5960
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
61+
githubToken: '',
6062
} as context.Inputs
6163
],
6264
[
@@ -76,6 +78,7 @@ describe('getInputs', () => {
7678
rootless: false,
7779
setHost: true,
7880
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
81+
githubToken: '',
7982
} as context.Inputs
8083
],
8184
[
@@ -97,6 +100,7 @@ describe('getInputs', () => {
97100
rootless: false,
98101
setHost: false,
99102
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
103+
githubToken: '',
100104
} as context.Inputs
101105
],
102106
[
@@ -116,6 +120,7 @@ describe('getInputs', () => {
116120
rootless: false,
117121
setHost: false,
118122
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
123+
githubToken: '',
119124
} as context.Inputs
120125
],
121126
[
@@ -136,6 +141,7 @@ describe('getInputs', () => {
136141
daemonConfig: '',
137142
rootless: false,
138143
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
144+
githubToken: '',
139145
} as context.Inputs
140146
],
141147
[
@@ -156,6 +162,7 @@ describe('getInputs', () => {
156162
daemonConfig: '',
157163
rootless: false,
158164
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
165+
githubToken: '',
159166
} as context.Inputs
160167
],
161168
[
@@ -175,6 +182,7 @@ describe('getInputs', () => {
175182
daemonConfig: '',
176183
rootless: false,
177184
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
185+
githubToken: '',
178186
} as context.Inputs
179187
],
180188
[
@@ -194,6 +202,7 @@ describe('getInputs', () => {
194202
daemonConfig: '',
195203
rootless: true,
196204
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
205+
githubToken: '',
197206
} as context.Inputs
198207
],
199208
[
@@ -216,6 +225,7 @@ describe('getInputs', () => {
216225
rootless: false,
217226
setHost: false,
218227
runtimeBasedir: path.join(os.homedir(), `setup-docker-action`),
228+
githubToken: '',
219229
} as context.Inputs
220230
],
221231
])(

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ inputs:
3434
runtime-basedir:
3535
description: 'Docker runtime base directory'
3636
required: false
37+
github-token:
38+
description: "GitHub Token used to get releases and download assets"
39+
default: ${{ github.token }}
40+
required: false
3741

3842
outputs:
3943
sock:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface Inputs {
1414
setHost: boolean;
1515
rootless: boolean;
1616
runtimeBasedir: string;
17+
githubToken: string;
1718
}
1819

1920
export function getInputs(): Inputs {
@@ -31,7 +32,8 @@ export function getInputs(): Inputs {
3132
context: core.getInput('context'),
3233
setHost: core.getBooleanInput('set-host'),
3334
rootless: core.getBooleanInput('rootless'),
34-
runtimeBasedir: core.getInput('runtime-basedir') || path.join(os.homedir(), `setup-docker-action`)
35+
runtimeBasedir: core.getInput('runtime-basedir') || path.join(os.homedir(), `setup-docker-action`),
36+
githubToken: core.getInput('github-token')
3537
};
3638
}
3739

src/main.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ actionsToolkit.run(
2525

2626
if (input.source.type === 'image') {
2727
await core.group(`Download and install regctl`, async () => {
28-
const regclientInstall = new RegclientInstall();
28+
const regclientInstall = new RegclientInstall({githubToken: input.githubToken});
2929
const regclientBinPath = await regclientInstall.download(
3030
process.env.REGCTL_VERSION && process.env.REGCTL_VERSION.trim()
3131
? process.env.REGCTL_VERSION
@@ -35,7 +35,7 @@ actionsToolkit.run(
3535
await regclientInstall.install(regclientBinPath);
3636
});
3737
await core.group(`Download and install undock`, async () => {
38-
const undockInstall = new UndockInstall();
38+
const undockInstall = new UndockInstall({githubToken: input.githubToken});
3939
const undockBinPath = await undockInstall.download(
4040
process.env.UNDOCK_VERSION && process.env.UNDOCK_VERSION.trim()
4141
? process.env.UNDOCK_VERSION
@@ -59,7 +59,8 @@ actionsToolkit.run(
5959
rootless: input.rootless,
6060
contextName: input.context || 'setup-docker-action',
6161
daemonConfig: input.daemonConfig,
62-
localTCPPort: tcpPort
62+
localTCPPort: tcpPort,
63+
githubToken: input.githubToken
6364
});
6465
let toolDir;
6566
if (!(await Docker.isAvailable()) || input.source) {

0 commit comments

Comments
 (0)