Skip to content

Commit

Permalink
Fix github_token parameter (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
amckinney authored Oct 26, 2021
1 parent b36ffc1 commit 3424b70
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: test
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: ./ # Run the local version of the action.
with:
version: 'latest'
github_token: ${{ github.token }}
- run: buf --version
6 changes: 3 additions & 3 deletions dist/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/main.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/buf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import { Error, isError } from './error';
// optionally be specified in the action's version parameter.
const versionPrefix = "v";

export async function getBuf(version: string, token: string): Promise<string|Error> {
export async function getBuf(version: string, githubToken: string): Promise<string|Error> {
const binaryPath = tc.find('buf', version, os.arch());
if (binaryPath !== '') {
core.info(`Found in cache @ ${binaryPath}`);
return binaryPath;
}

core.info(`Resolving the download URL for the current platform...`);
const downloadURL = await getDownloadURL(version);
const downloadURL = await getDownloadURL(version, githubToken);
if (isError(downloadURL)) {
return downloadURL
}
Expand Down Expand Up @@ -68,7 +68,7 @@ export async function getBuf(version: string, token: string): Promise<string|Err

// getDownloadURL resolves Buf's Github download URL for the
// current architecture and platform.
async function getDownloadURL(version: string, token: string): Promise<string|Error> {
async function getDownloadURL(version: string, githubToken: string): Promise<string|Error> {
let architecture = '';
switch (os.arch()) {
// The available architectures can be found at:
Expand Down Expand Up @@ -111,7 +111,7 @@ async function getDownloadURL(version: string, token: string): Promise<string|Er
} else {
assetName = `buf-${platform}-${architecture}.tar.gz`
}
const octokit = new Octokit({ auth: token });
const octokit = new Octokit({ auth: githubToken });
const {data: releases} = await octokit.request(
'GET /repos/{owner}/{repo}/releases',
{
Expand Down

0 comments on commit 3424b70

Please sign in to comment.