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

github.proxy not worked? #863

Closed
afeiship opened this issue Jan 25, 2022 · 4 comments
Closed

github.proxy not worked? #863

afeiship opened this issue Jan 25, 2022 · 4 comments

Comments

@afeiship
Copy link

afeiship commented Jan 25, 2022

proxy

https://github.com/release-it/release-it/blob/master/lib/plugin/github/GitHub.js#L170

get client() {
    if (this._client) return this._client;
    const { proxy, timeout } = this.options;
    const host = this.options.host || this.getContext('repo.host');
    const isGitHub = host === 'github.com';
    const baseUrl = `https://${isGitHub ? 'api.github.com' : host}${isGitHub ? '' : '/api/v3'}`;
    const options = {
        baseUrl,
        auth: `token ${this.token}`,
        userAgent: `release-it/${pkg.version}`,
        log: this.config.isDebug ? console : null,
        request: {
            timeout
        }
    };

    if (proxy) {
        options.proxy = proxy;
        // so, maybe this should be worked?
        options.request.agent = new ProxyAgent(proxy);
    }

    const client = new Octokit(options);

    this._client = client;
    return client;
}

my case

not worked when i only use proxy

worked when i add options.request.agent = new Proxy(options.proxy)

@afeiship afeiship changed the title git.proxy not worked? github.proxy not worked? Jan 25, 2022
@afeiship afeiship reopened this Jan 25, 2022
@webpro
Copy link
Collaborator

webpro commented Mar 21, 2022

Interesting. Could you please open a PR with this fix?

Maybe there has been an update in @octokit/rest or @octokit/request I've missed.

dgcofer added a commit to dgcofer/release-it that referenced this issue Apr 14, 2022
Based on a recent change in Octokits docs[1], in order for it to use a
configured proxy you must pass another request.agent into the Octokit
constructor. This change adds the `proxy-agent` lib as suggested by
Octokits docs.

Note that with this implmentation, the `http_proxy` or `https_proxy`
environment variables alone will NOT work. Instead one must explicitly
set the value in the `github.proxy` option passed to release-it. This is
to stay inline with current behavior[2].

[1] octokit/octokit.js@2090c85
[2] https://github.com/release-it/release-it/blob/14.14.2/docs/github-releases.md#proxy
webpro pushed a commit that referenced this issue Apr 14, 2022
Based on a recent change in Octokits docs[1], in order for it to use a
configured proxy you must pass another request.agent into the Octokit
constructor. This change adds the `proxy-agent` lib as suggested by
Octokits docs.

Note that with this implmentation, the `http_proxy` or `https_proxy`
environment variables alone will NOT work. Instead one must explicitly
set the value in the `github.proxy` option passed to release-it. This is
to stay inline with current behavior[2].

[1] octokit/octokit.js@2090c85
[2] https://github.com/release-it/release-it/blob/14.14.2/docs/github-releases.md#proxy
@afeiship
Copy link
Author

@webpro thx, you have fixed the bug in new version. :)
I have a template script to fix in my project, waiting for new verison release!

// 1. Add proxy to `.release-it.json`
// 2. ./node_modules/release-it/lib/plugin/github/GitHub.js
// 3. const prompts = require('./prompts'); ---> const ProxyAgent = require('proxy-agent');
// 4. options.proxy = proxy; --->  options.request.agent = new ProxyAgent(proxy);
// 5. add proxy to package.json

@webpro
Copy link
Collaborator

webpro commented Apr 29, 2022

Sorry @afeiship! I pushed to code to test it in the GitHub Action, but forgot to release-it! It's in v14.14.3

@afeiship
Copy link
Author

afeiship commented Apr 30, 2022

@webpro thanks, I have installed(v14.14.3) it in my project, it worked!

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

No branches or pull requests

2 participants