Skip to content

Commit 15c905b

Browse files
authored
Merge pull request #196 from crazy-max/dl-no-token
don't depend on the GitHub API to check release
2 parents 0648fd6 + a25d6a0 commit 15c905b

16 files changed

+63
-794
lines changed

.github/workflows/test.yml

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ jobs:
3030
uses: docker/bake-action@v2
3131
with:
3232
targets: test
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3533
-
3634
name: Upload coverage
3735
uses: codecov/codecov-action@v3

README.md

-30
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ___
2828
* [Notes](#notes)
2929
* [`nodes` output](#nodes-output)
3030
* [BuildKit container logs](#buildkit-container-logs)
31-
* [Using on GHES](#using-on-ghes)
3231
* [Contributing](#contributing)
3332

3433
## Usage
@@ -175,35 +174,6 @@ The following [official docker environment variables](https://docs.docker.com/en
175174

176175
See https://docs.docker.com/build/ci/github-actions/configure-builder/#buildkit-container-logs
177176

178-
## Using on GHES
179-
180-
GitHub Runners come [pre-installed with Docker Buildx](https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md)
181-
following your virtual environment. If you specify a version or `latest` of
182-
Docker Buildx in your workflow, the version will be downloaded from [GitHub Releases in `docker/buildx`](https://github.com/docker/buildx/releases)
183-
repository. These calls to `docker/buildx` are made via unauthenticated requests,
184-
which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting).
185-
186-
If more requests are made within the time frame, then you will start to see
187-
rate-limit errors during downloading that looks like:
188-
189-
```
190-
##[error]API rate limit exceeded for...
191-
```
192-
193-
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new)
194-
and pass it as the `github_token` input for the action:
195-
196-
```yaml
197-
uses: docker/setup-buildx-action@v2
198-
with:
199-
github_token: ${{ secrets.GH_DOTCOM_TOKEN }}
200-
version: v0.10.1
201-
```
202-
203-
If the runner is not able to access `github.com`, it will take the default one
204-
available on the GitHub Runner or runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)"
205-
for more information.
206-
207177
## Contributing
208178

209179
Want to contribute? Awesome! You can find information about contributing to

__tests__/buildx.test.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,34 @@ describe('isAvailable', () => {
2828
});
2929
});
3030

31+
describe('getRelease', () => {
32+
it('returns latest buildx GitHub release', async () => {
33+
const release = await buildx.getRelease('latest');
34+
expect(release).not.toBeNull();
35+
expect(release?.tag_name).not.toEqual('');
36+
});
37+
38+
it('returns v0.10.1 buildx GitHub release', async () => {
39+
const release = await buildx.getRelease('v0.10.1');
40+
expect(release).not.toBeNull();
41+
expect(release?.id).toEqual(90346950);
42+
expect(release?.tag_name).toEqual('v0.10.1');
43+
expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.10.1');
44+
});
45+
46+
it('returns v0.2.2 buildx GitHub release', async () => {
47+
const release = await buildx.getRelease('v0.2.2');
48+
expect(release).not.toBeNull();
49+
expect(release?.id).toEqual(17671545);
50+
expect(release?.tag_name).toEqual('v0.2.2');
51+
expect(release?.html_url).toEqual('https://github.com/docker/buildx/releases/tag/v0.2.2');
52+
});
53+
54+
it('unknown release', async () => {
55+
await expect(buildx.getRelease('foo')).rejects.toThrowError(new Error('Cannot find Buildx release foo in https://raw.githubusercontent.com/docker/buildx/master/.github/releases.json'));
56+
});
57+
});
58+
3159
describe('isAvailable standalone', () => {
3260
const execSpy = jest.spyOn(exec, 'getExecOutput');
3361
buildx.isAvailable(true);
@@ -221,7 +249,7 @@ describe('install', () => {
221249
])(
222250
'acquires %p of buildx (standalone: %p)',
223251
async (version, standalone) => {
224-
const buildxBin = await buildx.install(version, process.env.GITHUB_TOKEN || '', tmpDir, standalone);
252+
const buildxBin = await buildx.install(version, tmpDir, standalone);
225253
expect(fs.existsSync(buildxBin)).toBe(true);
226254
},
227255
100000

__tests__/github.test.ts

-20
This file was deleted.

action.yml

-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ inputs:
4444
append:
4545
description: 'Append additional nodes to the builder'
4646
required: false
47-
github_token:
48-
# https://github.com/actions/setup-go/blob/21459d0b7b1d63741429b748885bf5a4974593b4/action.yml#L12-L14
49-
description: >
50-
Used to verifiy the Git tag exists on docker/buildx repo. Since there's a
51-
default, this is typically not supplied by the user. When running this
52-
action on github.com, the default value is sufficient. When running on
53-
GHES, you can pass a personal access token for github.com if you are
54-
experiencing rate limiting.
55-
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
5647

5748
outputs:
5849
name:

dev.Dockerfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ RUN --mount=type=bind,target=.,rw \
7272
--mount=type=cache,target=/src/node_modules \
7373
--mount=type=bind,from=docker,source=/usr/local/bin/docker,target=/usr/bin/docker \
7474
--mount=type=bind,from=buildx,source=/buildx,target=/usr/libexec/docker/cli-plugins/docker-buildx \
75-
--mount=type=secret,id=GITHUB_TOKEN \
76-
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test --coverageDirectory=/tmp/coverage
75+
yarn run test --coverageDirectory=/tmp/coverage
7776

7877
FROM scratch AS test-coverage
7978
COPY --from=test /tmp/coverage /

dist/index.js

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

dist/index.js.map

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

0 commit comments

Comments
 (0)