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 HTTPS Proxy Support for Fetch Requests #582

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GwiYeong
Copy link

Description:

This PR introduces support for HTTPS proxy configuration in fetch requests. The changes allow the application to route HTTP requests through a specified proxy server, enhancing security and network configuration flexibility.

Changes:

  1. Proxy Configuration:
  • Added logic to check for https_proxy or HTTPS_PROXY environment variables.
    Implemented a custom fetch function that utilizes undici's ProxyAgent to route requests through the specified proxy.
  1. Request Initialization:
  • Modified the request initialization to include the dispatcher property with ProxyAgent when a proxy is detected.

Code Changes:

  • File: src/action.ts
    • Added import statements for undiciFetch, ProxyAgent, and RequestInit from undici.
    • Introduced a new conditional block to check for https_proxy environment variables and configure the fetch requests accordingly.
    • Updated the Octokit initialization to include the custom fetch function when a proxy is used.

Example Usage:

To utilize the proxy support, set the https_proxy or HTTPS_PROXY environment variable before running the action:

jobs:
  deploy:
    steps:
      - name: Deploy
        uses: fjogeleit/yaml-update-action@main
        env:
          HTTPS_PROXY: http://dev-lypwg01-001.yahoo-net.jp:8080
    ...

@fjogeleit
Copy link
Owner

thanks for your contribution and sorry for the late response, will try to take a deeper look this week.

Is there a reason that you did not add undici to the package,json as dependency? And why you used an env var instead of an action value?

@fjogeleit fjogeleit self-requested a review July 19, 2024 07:31
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 this pull request may close these issues.

2 participants