How to Use a Proxy in GitHub Actions: Secrets and Env Vars

Published:

11 minute read

Acar Diveroli
Written by: Acar Diveroli
Four stacked step plates with only FETCH in blue; a cable from a locked PROXY_URL box connects to it alone, a clock beside

In GitHub Actions, a proxy is the exit address you give a workflow step through the HTTPS_PROXY environment variable. The address carries a password, so it lives in a repository secret and reaches only the step that needs it, through an env: block. Set the variable for the whole job and checkout, package installs and artifact uploads also go through the proxy. This post covers the secret setup, the step-level variable, the NO_PROXY list, the gaps in log masking, scheduled data jobs and the self-hosted runner setup.

The proxy URL in a secret

A proxy URL carries a username and password, so it does not go into the workflow file. In the repository, open Settings → Secrets and variables → Actions and create a secret named PROXY_URL with New repository secret. If you prefer the command line, gh secret set PROXY_URL prompts you for the value.

Enter the value as the full URL:

text
http://user:pass%40123@pr.proxynet.io:8000

If the password contains @, :, / or #, write it with percent-encoding. In our test, an unencoded pass@123 password made curl 8.23.0 fail with (5) Unsupported proxy syntax. The error line printed the whole URL, password included. The encoding rules are in our post on the parts of a proxy URL.

Secrets are not passed to runs triggered by pull requests from forks. An undefined secret comes back as an empty string. An empty HTTPS_PROXY raises no error: the request quietly leaves from the runner's own IP. That is why the IP check at the start of the step matters.

The variable only on the data step

Every process at the level where you write an env: block sees the variable. An HTTPS_PROXY set at job level reaches every step in the job. Most of those steps read the proxy from the environment. git follows https_proxy, and so does pip. The Actions network library, @actions/http-client, reads https_proxy and HTTPS_PROXY explicitly in its source code. The artifact and cache clients follow the proxy in the environment too.

Stepenv at job levelenv on the data step only
actions/checkout (git)Through the proxyDirect
pip installThrough the proxyDirect
upload-artifact, cacheThrough the proxyDirect
Data scriptThrough the proxyThrough the proxy

The cost is traffic and time. Dependency downloads and artifact uploads eat into your proxy quota, and a distant exit node slows down the setup. Give the variable only to the step that sends requests to the outside site:

yaml
- name: Fetch data
  env:
    HTTPS_PROXY: ${{ secrets.PROXY_URL }}
  run: python fetch.py --out data.json

The variable name matters. An HTTPS target needs HTTPS_PROXY. In our test, with only http_proxy set, curl reached an HTTPS target without the proxy and reported no error. Other cases where environment variables get skipped are in why HTTP_PROXY is not applied.

GitHub hosts and NO_PROXY

NO_PROXY is a comma-separated list of names that go direct, bypassing the proxy. If the data step only talks to the outside site, you do not need the list. If the same step runs a gh command, writes results to the API or does a git push, the GitHub hosts go on the list.

yaml
env:
  HTTPS_PROXY: ${{ secrets.PROXY_URL }}
  NO_PROXY: github.com,githubusercontent.com,blob.core.windows.net

A domain on the list also covers its subdomains. The github.com entry matches api.github.com and codeload.github.com, and the githubusercontent.com entry matches results-receiver.actions.githubusercontent.com. GitHub's documentation also lists the *.blob.core.windows.net domain for artifact, cache and log traffic.

In our test with this list, curl sent the api.github.com and raw.githubusercontent.com requests direct. Requests also sent the api.github.com request without the proxy. Only the api.ipify.org tunnel showed up in the test proxy's log. With the list removed, a tunnel opened for api.github.com too. @actions/http-client follows the same rule: if the target name equals an entry or ends with .entry, the request goes direct.

Masking and leaked fragments

GitHub replaces a secret's value with *** wherever it sees it in the log. The match is made on the exact text. GitHub's security documentation therefore does not guarantee masking of transformed values and asks you to register each derived value separately.

A proxy URL produces two derived values. One is the decoded password: the secret holds pass%40123, but the tool uses pass@123. The other is the Base64 value in the Proxy-Authorization header. In our test, curl -v printed two lines:

text
* Uses proxy env variable https_proxy == 'http://user:pass%40123@127.0.0.1:18080'
> Proxy-Authorization: Basic dXNlcjpwYXNzQDEyMw==

The URL on the first line is the secret itself and gets masked. The Base64 on the second line decodes to user:pass@123. That text does not appear in the secret, so under the exact-match rule it stays visible in the log. The fix is to register the derived values with the ::add-mask:: command at the start of the step:

python
# .github/scripts/mask_proxy.py
import base64
import os
import urllib.parse as up

u = up.urlsplit(os.environ["HTTPS_PROXY"])
user = up.unquote(u.username or "")
pw = up.unquote(u.password or "")
for value in (pw, base64.b64encode(f"{user}:{pw}".encode()).decode()):
    if value:
        print(f"::add-mask::{value}")

You register a mask once per value within a job, and it stays in effect for later steps. Do not use curl -v, set -x or echo $HTTPS_PROXY in the workflow. Do not write the URL to the GITHUB_ENV file either: it spreads to every later step.

Scheduled data jobs

The schedule trigger runs a workflow from a cron expression. According to the documentation, the shortest interval is 5 minutes, the time is UTC by default, and the job runs on the latest commit of the default branch. The optional timezone key takes an IANA time zone. For Türkiye, you write Europe/Istanbul.

The top of the hour is the busiest time. Jobs that start in those minutes can be delayed, and if the load gets very high, queued jobs can be dropped. Pick a minute other than 0. In a public repository, a scheduled workflow is disabled automatically after 60 days without activity.

yaml
name: Daily data pull

on:
  schedule:
    - cron: "17 9 * * *"
      timezone: "Europe/Istanbul"
  workflow_dispatch:

permissions:
  contents: read

jobs:
  pull:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-python@v7
        with:
          python-version: "3.13"
      - run: pip install requests

      - name: Mask the proxy and verify the exit IP
        env:
          HTTPS_PROXY: ${{ secrets.PROXY_URL }}
        run: |
          python .github/scripts/mask_proxy.py
          direct=$(curl -sS --max-time 20 --noproxy '*' https://api.ipify.org)
          via=$(curl -sS --max-time 20 --fail https://api.ipify.org)
          echo "Exit IP: $via"
          if [ "$via" = "$direct" ]; then
            echo "::error::Request did not go through the proxy"
            exit 1
          fi

      - name: Fetch data
        env:
          HTTPS_PROXY: ${{ secrets.PROXY_URL }}
          NO_PROXY: github.com,githubusercontent.com,blob.core.windows.net
        run: python fetch.py --out data.json

      - uses: actions/upload-artifact@v7
        with:
          name: data
          path: data.json

The IP check sends two requests. One gets the runner's own address with --noproxy '*', the other gets the proxy's exit. If both addresses match, the step ends with an error code and the data step never runs. workflow_dispatch lets you start the job by hand, so you can test it without waiting for the cron.

A scheduled job goes to the same site every day. Follow the site's terms and robots.txt, and keep the request rate low. For jobs that pull data from one country on a regular basis, Residential Proxy is a good first option.

Proxy on a self-hosted runner

For a self-hosted runner's own connection, you set the proxy with the https_proxy, http_proxy and no_proxy variables that the runner application reads. If the runner runs as a service under a system account, the variables go into the .env file in the runner's installation folder:

text
https_proxy=http://user:pass%40123@pr.proxynet.io:8000
no_proxy=localhost,build.internal

GitHub's documentation gives four details. The variables are read when the runner starts, so restart the runner after a change. On Linux and macOS, if both letter cases are set, the lowercase one wins. no_proxy does not support IP addresses or CIDR ranges. Docker container actions and service containers may also need Docker's own proxy setting.

This file sets the path the runner uses to reach GitHub. If all of the runner's traffic must leave through a proxy, for example when a proxy is the network's only way out, the URL goes here. Log, artifact and action download traffic then go through the proxy too. If only the data job needs the proxy, leave the file alone. Keep the URL in a secret and pass it to the step.

.env values are not secrets and are not masked. When you check whether a step sees these variables, print only their names: env | grep -i '_proxy=' | cut -d= -f1.

Debugging

SymptomCauseFix
The check step shows the runner IPVariable not passed to that step, or the secret is emptyCheck the step's env: block and the secret name
HTTPS target goes without the proxyOnly http_proxy is setSet HTTPS_PROXY
curl: (5) Unsupported proxy syntaxUnencoded @ in the passwordWrite it as %40 in the secret
407 Proxy Authentication RequiredWrong username or passwordRe-enter the secret, check the encoding
gh or git push goes through the proxyNO_PROXY missingAdd the GitHub domains to the list
Scheduled job starts lateTop-of-the-hour loadMove the minute away from 0

If you see a plain Base64 string in the log instead of ***, the problem is masking. Delete the run log, change the password and register the derived values with ::add-mask::.

How we tested

We did not run GitHub Actions. On December 2, 2026, we compared the YAML examples against the docs.github.com documentation. The action versions are the latest major versions released as of that day. We ran the shell and Python parts locally the same day: Git Bash on Windows 11, curl 8.23.0, Python 3.13.17 and Requests 2.34.2. The targets were api.ipify.org and api.github.com. In between sat a local test proxy that required Basic authentication and logged every CONNECT request and the decoded credentials. Because the test proxy exited through our own line, the IP check failed here on purpose, which confirmed the error path.

The bottom line

Keep the proxy URL in a secret, pass it only to the data step, and register the masks and check the exit IP at the start of that step. Above all, do not set HTTPS_PROXY at job level: the whole job goes through the proxy and no step reports an error. For jobs that must leave from the same address on every run, Static Proxy is an option.

Sources

Frequently asked questions

Where do I put the proxy URL in GitHub Actions?

In a repository secret. Under Settings → Secrets and variables → Actions, save the full URL with the name PROXY_URL. In the workflow, pass the value to the step's env: block with ${{ secrets.PROXY_URL }}. Do not write the URL in plain text in the YAML file, because it stays in the repository history. Enter special characters in the password with percent-encoding.

Should HTTPS_PROXY be set at job level or step level?

At step level. A job-level variable reaches every step, such as checkout, pip and artifact upload, and those steps read the proxy from the environment. As a result, dependency downloads also eat into your proxy traffic. Give the variable only to the step that sends requests to the outside site. The other steps use the runner's own connection.

Does a secret always show as *** in the log?

No. Masking works by exact text match. The secret itself is hidden, but the decoded password or the Base64 value in the Proxy-Authorization header is different text and can stay visible. Register these derived values with ::add-mask:: at the start of the step, and do not use curl -v or set -x.

Which GitHub hosts go on the NO_PROXY list?

If the step also sends requests to GitHub, github.com, githubusercontent.com and blob.core.windows.net are a solid start. A domain also covers its subdomains, so you do not list api.github.com separately. If the step only talks to the outside site, you do not need the list. A self-hosted runner's no_proxy list does not support IP addresses.

Can a scheduled workflow run on Türkiye time?

Yes, with the timezone key. If you add timezone: "Europe/Istanbul" under the cron line, the expression is read in Türkiye time. Without the key, the time is UTC. Jobs can be delayed at the top of the hour, so pick a minute other than 0. In a public repository, the schedule is disabled after 60 days without activity.

How do I set a proxy on a self-hosted runner?

With the .env file in the runner folder. Add https_proxy, http_proxy and no_proxy lines to the file, then restart the runner. This setting decides how the runner connects to GitHub. Do not put the data job's proxy here: pass it to the right step through a secret. Docker container actions may also need Docker's proxy setting.

Ask ChatGPTAsk Claude