Skip to content

Commit a024221

Browse files
authored
Merge pull request #191 from crazy-max/fix-dl-release
use Octokit client to download buildx
2 parents 7932f62 + 4c3fce4 commit a024221

File tree

15 files changed

+733
-21
lines changed

15 files changed

+733
-21
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
uses: docker/bake-action@v2
3131
with:
3232
targets: test
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3335
-
3436
name: Upload coverage
3537
uses: codecov/codecov-action@v3

__tests__/buildx.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ describe('install', () => {
221221
])(
222222
'acquires %p of buildx (standalone: %p)',
223223
async (version, standalone) => {
224-
const buildxBin = await buildx.install(version, tmpDir, standalone);
224+
const buildxBin = await buildx.install(version, process.env.GITHUB_TOKEN || '', tmpDir, standalone);
225225
expect(fs.existsSync(buildxBin)).toBe(true);
226226
},
227227
100000

__tests__/github.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ import * as github from '../src/github';
33

44
describe('github', () => {
55
it('returns latest buildx GitHub release', async () => {
6-
const release = await github.getRelease('latest');
6+
const release = await github.getLatestRelease(process.env.GITHUB_TOKEN || '');
77
expect(release).not.toBeNull();
88
expect(release?.tag_name).not.toEqual('');
99
});
1010

1111
it('returns v0.2.2 buildx GitHub release', async () => {
12-
const release = await github.getRelease('v0.2.2');
12+
const release = await github.getReleaseTag('v0.2.2', process.env.GITHUB_TOKEN || '');
1313
expect(release).not.toBeNull();
1414
expect(release?.tag_name).toEqual('v0.2.2');
1515
});
16+
17+
it('unknown release', async () => {
18+
await expect(github.getReleaseTag('foo', process.env.GITHUB_TOKEN || '')).rejects.toThrowError(new Error('Cannot get release foo: HttpError: Not Found'));
19+
});
1620
});

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ inputs:
4444
append:
4545
description: 'Append additional nodes to the builder'
4646
required: false
47+
github_token:
48+
description: 'The GitHub token used to create an authenticated client for GitHub API'
49+
default: ${{ github.token }}
50+
required: false
4751

4852
outputs:
4953
name:

dev.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ 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-
yarn run test --coverageDirectory=/tmp/coverage
75+
--mount=type=secret,id=GITHUB_TOKEN \
76+
GITHUB_TOKEN=$(cat /run/secrets/GITHUB_TOKEN) yarn run test --coverageDirectory=/tmp/coverage
7677

7778
FROM scratch AS test-coverage
7879
COPY --from=test /tmp/coverage /

dist/index.js

Lines changed: 8 additions & 2 deletions
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.

dist/licenses.txt

Lines changed: 524 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-bake.hcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ target "test" {
5050
dockerfile = "dev.Dockerfile"
5151
target = "test-coverage"
5252
output = ["./coverage"]
53+
secret = ["id=GITHUB_TOKEN,env=GITHUB_TOKEN"]
5354
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@actions/core": "^1.10.0",
3131
"@actions/exec": "^1.1.1",
32-
"@actions/http-client": "^2.0.1",
32+
"@actions/github": "^5.1.1",
3333
"@actions/tool-cache": "^2.0.1",
3434
"csv-parse": "^5.3.3",
3535
"js-yaml": "^4.1.0",

0 commit comments

Comments
 (0)