Skip to content

Commit

Permalink
Add proxy agent (#75)
Browse files Browse the repository at this point in the history
Support the use of `http_proxy` when looking up releases via GitHub URL.
  • Loading branch information
sjdaws committed Nov 28, 2022
1 parent a8ba580 commit ffdd84c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 21 deletions.
25 changes: 18 additions & 7 deletions dist/main.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

51 changes: 44 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -17,12 +17,13 @@
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
"@actions/io": "^1.1.2",
"@actions/tool-cache": "^2.0.1"
"@actions/tool-cache": "^2.0.1",
"https-proxy-agent": "^5.0.1"
},
"devDependencies": {
"@types/node": "^18.7.14",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"@types/node": "^18.7.14",
"esbuild": "^0.15.10",
"prettier": "^2.7.1",
"typescript": "^4.8.4"
Expand Down
11 changes: 10 additions & 1 deletion src/buf.ts
Expand Up @@ -18,6 +18,7 @@ import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";
import { Octokit } from "@octokit/core";
import { Error, isError } from "./error";
import { HttpsProxyAgent } from "https-proxy-agent";

// versionPrefix is used in Github release names, and can
// optionally be specified in the action's version parameter.
Expand Down Expand Up @@ -129,7 +130,15 @@ async function getDownloadURL(
} else {
assetName = `buf-${platform}-${architecture}.tar.gz`;
}
const octokit = new Octokit({ auth: githubToken });
const requestAgent = process.env.http_proxy
? new HttpsProxyAgent(process.env.http_proxy)
: undefined;
const octokit = new Octokit({
auth: githubToken,
request: {
agent: requestAgent,
},
});
if (version === "latest") {
const { data: releases } = await octokit.request(
"GET /repos/{owner}/{repo}/releases",
Expand Down

0 comments on commit ffdd84c

Please sign in to comment.