Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy agent #75

Merged
merged 2 commits into from Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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