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

Support for proxy #206

Closed
cojocar opened this issue Feb 9, 2022 · 3 comments · Fixed by #386
Closed

Support for proxy #206

cojocar opened this issue Feb 9, 2022 · 3 comments · Fixed by #386

Comments

@cojocar
Copy link

cojocar commented Feb 9, 2022

Hi,

are the proxy environment variables supported when uploading the assets for the release?

I'm getting the following error and I'm an environment that uses an http/https proxy.

Run softprops/action-gh-release@v1
👩‍🏭 Creating new GitHub release for tag v0.10...
⬆️ Uploading myhello-v0.10_debug.zip...
⬆️ Uploading myhello-v0.10_release.zip...
Error: request to https://uploads.github.com/[redacted][7](https://github.com/[redacted]?check_suite_focus=true#step:8:7)41[8](https://github.com/[redacted]?check_suite_focus=true#step:8:8)2/assets?name=myhello-v0.[10](https://github.com/[redacted]?check_suite_focus=true#step:8:10)_debug.zip failed, reason: connect ETIMEDOUT 140.82.112.13:443

The release is created fine though, but the assets are missing.

@gabe-brussa
Copy link

+1

@lordmauve
Copy link

lordmauve commented Nov 23, 2022

This is due to using node-fetch which declined to add proxy support.

It's quite a simple fix to use the octokit request API, which honours proxy settings and automatically supplies the access token:

diff --git a/package.json b/package.json
index c0275f4..12e33a8 100644
--- a/package.json
+++ b/package.json
@@ -24,15 +24,13 @@
     "@octokit/plugin-retry": "^4.0.3",
     "@octokit/plugin-throttling": "^4.3.2",
     "glob": "^8.0.3",
-    "mime": "^3.0.0",
-    "node-fetch": "^2.6.7"
+    "mime": "^3.0.0"
   },
   "devDependencies": {
     "@types/glob": "^8.0.0",
     "@types/jest": "^29.2.3",
     "@types/mime": "^3.0.1",
     "@types/node": "^18.11.9",
-    "@types/node-fetch": "^2.5.12",
     "@vercel/ncc": "^0.34.0",
     "jest": "^29.3.1",
     "jest-circus": "^29.3.1",
diff --git a/src/github.ts b/src/github.ts
index f4a0402..d91084c 100644
--- a/src/github.ts
+++ b/src/github.ts
@@ -1,4 +1,3 @@
-import fetch from "node-fetch";
 import { GitHub } from "@actions/github/lib/utils";
 import { Config, isTag, releaseBody } from "./util";
 import { statSync, readFileSync } from "fs";
@@ -159,16 +158,16 @@ export const upload = async (
   console.log(`⬆️ Uploading ${name}...`);
   const endpoint = new URL(url);
   endpoint.searchParams.append("name", name);
-  const resp = await fetch(endpoint, {
+  const resp = await github.request({
+    method: "POST",
+    url: endpoint.toString(),
     headers: {
       "content-length": `${size}`,
       "content-type": mime,
-      authorization: `token ${config.github_token}`,
     },
-    method: "POST",
-    body,
+    data: body,
   });
-  const json = await resp.json();
+  const json = resp.data;
   if (resp.status !== 201) {
     throw new Error(
       `Failed to upload release asset ${name}. received status code ${

@timor-raiman
Copy link
Contributor

+1

softprops added a commit that referenced this issue Mar 8, 2024
* manually adopt and apply patch from #206 (comment)

* rebuild

---------

Co-authored-by: Doug Tangren <d.tangren@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants