# Static IP in GitHub Actions

Source: https://prontaro.com/docs/integrations/github-actions/

Send only the workflow steps that need an allowlisted address through a dedicated IPv4, keeping firewalls closed to GitHub's cloud ranges.

GitHub-hosted runners exit from thousands of Azure IP addresses whose CIDR list changes every week. With Prontaro, regular builds and package installs run directly as usual, while protected steps use a proxy URL, a Relay URL, or the single-binary `prontaro forward` command for database migrations and SSH/SFTP deploys.

## Which method to choose

| CI task | Prontaro method | CLI install needed? |
| --- | --- | --- |
| **REST API calls, webhooks, smoke tests (`curl`, Node, Python, Go)** | `PRONTARO_PROXY_URL` / `HTTPS_PROXY` on that step | No |
| **Simple HTTP call to one allowlisted host** | `PRONTARO_RELAY_URL` | No |
| **Database migrations (`psql`, Prisma, Flyway) or SSH/SFTP deploys** | `prontaro` CLI + `prontaro forward` with `PRONTARO_KEY` | Yes (single static binary) |

## Prerequisites

- A Prontaro account on Dedicated or Pro ([plans](https://prontaro.com/docs/billing/plans.md)). Open [my.prontaro.com/ips](https://my.prontaro.com/ips), pick a location, and click **Add IP**.
- Your dedicated IPv4 (`/32`) added to the destination API, database, or firewall allowlist.
- Access to **Settings → Secrets and variables → Actions** in your GitHub repository.

## Step 1. Create separate credentials for CI

### Path A. Proxy credentials and Relay

1. Open **IP addresses** in [my.prontaro.com](https://my.prontaro.com/ips), select your IP, and click **Create proxy credentials** (for example, `github-actions`).
2. Copy the `HTTPS` URL (`https://u_ci:s3cr3t@<entry>.prontaro.io:443`), or `SOCKS5` (`socks5h://...`).
3. If you only need a [Relay URL](https://prontaro.com/docs/outbound/relay.md) for one host, click **Add relay address** and enter `api.example.com`.

IP addresses Proxy credentials [Open in dashboard](https://my.prontaro.com/ips)

Leave the **To** destination list open until Step 5 so the `api.ipify.org` check in Step 4 succeeds.

### Path B. `prontaro CLI` token

In the Prontaro dashboard, open **CLI → New token**, create a dedicated CLI token named `github-actions`, and copy it. You can revoke it independently of your workstation.

CLI New token [Open in dashboard](https://my.prontaro.com/cli)

## Step 2. Store secrets in GitHub Actions

Add the secrets to your repository (or scope them inside a protected GitHub Environment such as `production` with required reviewers):

**Settings → Secrets and variables → Actions → New repository secret**

- `PRONTARO_PROXY_URL`: `https://u_ci:s3cr3t@<entry>.prontaro.io:443`
- `PRONTARO_RELAY_URL`: `https://relay-3f9c2a7e-5b1d-4c8a-9e60-1d2b3c4d5e6f.prontaro.run`
- `PRONTARO_KEY`: `prontaro.<cli-token>`

Only create the secrets your workflow needs (`PRONTARO_PROXY_URL` / `PRONTARO_RELAY_URL` for Path A, `PRONTARO_KEY` for Path B). Pass them only in the `env:` block of the specific step that uses them.

## Step 3. Configure your workflow

### Path A. Static IP without installing the CLI

Pass `PRONTARO_PROXY_URL` to `curl` or your script on a single step:

```yaml
# .github/workflows/partner-sync.yml
name: Partner API sync
on:
  workflow_dispatch:

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Call allowlisted partner API via proxy
        env:
          PRONTARO_PROXY_URL: ${{ secrets.PRONTARO_PROXY_URL }}
          PARTNER_API_TOKEN: ${{ secrets.PARTNER_API_TOKEN }}
        run: |
          curl -fsS --proxy "$PRONTARO_PROXY_URL" \
            -H "Authorization: Bearer $PARTNER_API_TOKEN" \
            https://api.example.com/v1/sync
```

When using a Relay URL (`PRONTARO_RELAY_URL`) for one host, omit `--proxy` and call the Relay base URL directly:

```yaml
      - name: Notify partner API via Relay URL
        env:
          PRONTARO_RELAY_URL: ${{ secrets.PRONTARO_RELAY_URL }}
          PARTNER_API_TOKEN: ${{ secrets.PARTNER_API_TOKEN }}
        run: |
          curl -fsS \
            -H "Authorization: Bearer $PARTNER_API_TOKEN" \
            "${PRONTARO_RELAY_URL%/}/v1/sync"
```

> **Keep HTTPS_PROXY scoped to one step**
>
> Never export `HTTPS_PROXY` at the job or workflow level — doing so routes `actions/checkout`, `npm ci`, Docker pulls, and artifact uploads through Prontaro, slowing down builds and consuming your monthly traffic allowance.

### Path B. Database migrations and SSH with `prontaro forward`

You do not need a `prontaro login` step in CI: `prontaro CLI` reads your token directly from `PRONTARO_KEY`. Install the binary, forward the target port to `127.0.0.1`, run the migration or deploy, and stop the background process with `trap`:

```yaml
# .github/workflows/migrate-and-deploy.yml
name: Migrate DB and deploy
on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install prontaro CLI
        run: |
          curl -fsSL https://prontaro.com/install.sh | sh
          echo "$HOME/.local/bin" >> "$GITHUB_PATH"

      - name: Run database migration through static IP
        env:
          PRONTARO_KEY: ${{ secrets.PRONTARO_KEY }}
          DATABASE_USER: ${{ secrets.DATABASE_USER }}
          DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
        run: |
          set -euo pipefail
          prontaro forward 15432 db.example.com:5432 --ip 203.0.113.10 &
          FWD_PID=$!
          trap 'kill "$FWD_PID" 2>/dev/null || true' EXIT

          for i in $(seq 1 30); do
            if nc -z 127.0.0.1 15432; then break; fi
            sleep 0.5
          done
          if ! nc -z 127.0.0.1 15432; then
            echo "prontaro forward did not become ready on 127.0.0.1:15432" >&2
            exit 1
          fi

          PGPASSWORD="$DATABASE_PASSWORD" psql \
            "postgresql://${DATABASE_USER}@127.0.0.1:15432/app?sslmode=require" \
            -f migrations/001_schema.sql
```

- **`sslmode=verify-full`:** `sslmode=require` encrypts the connection tunneled over `127.0.0.1` without verifying the hostname. For drivers enforcing `verify-full`, see [Local port forwarding (`prontaro forward`)](https://prontaro.com/docs/outbound/forward.md).
- **SSH and SFTP:** forward `deploy.example.com:22` to port `2222` and verify `known_hosts` with `HostKeyAlias`: `ssh -p 2222 -o HostKeyAlias=deploy.example.com deploy@127.0.0.1`.

## Step 4. Verify the outbound IP in Actions

Add this step to a `workflow_dispatch` workflow and run it manually to confirm the runner exits from your dedicated IPv4:

```yaml
      - name: Verify static IP
        env:
          PRONTARO_PROXY_URL: ${{ secrets.PRONTARO_PROXY_URL }}
        run: curl -fsS --proxy "$PRONTARO_PROXY_URL" https://api.ipify.org
```

Expected step log output:

```text
203.0.113.10
```

## Step 5. Lock down allowed targets (recommended)

Once verified, restrict your CI proxy credentials to the exact hosts and ports your pipeline calls:

1. Open **IP addresses → Proxy credentials** in [my.prontaro.com](https://my.prontaro.com/ips), select `github-actions`, and switch to the **Access** tab.
2. Add `api.example.com:443` under **To** and save.

IP addresses Proxy credentials Access [Open in dashboard](https://my.prontaro.com/ips)

## Security and CI notes

- **Restrict fork pull requests.** Never expose secrets in `pull_request_target` or untrusted forks. Keep them in protected Environments restricted to `main` or release tags.
- **Stop background `prontaro forward`.** Always terminate it with `trap 'kill "$FWD_PID" 2>/dev/null || true' EXIT` in the same step — otherwise the background process keeps stdout and stderr open and hangs the job.
- **Pass `--ip` with multiple IPs.** On Pro accounts with two or more IPs, `prontaro forward` cannot prompt in CI and exits with an error unless `--ip <IP>` is set.
- **Verify SHA256 in strict pipelines.** If policy disallows piping into `sh`, download the archive and [`SHA256SUMS`](https://prontaro.com/docs/cli/linux.md) from releases and check with `sha256sum -c`.

## Common errors

| Error | Cause | Fix |
| --- | --- | --- |
| `client_key_invalid` or `no saved login` | `PRONTARO_KEY` secret is empty, revoked, or unavailable in the current Environment/fork. | Check the `PRONTARO_KEY` secret name and rules under **Settings → Environments**. |
| `You have 2 addresses — choose which one to go out from` | Account has multiple IPs and `--ip` was omitted in non-interactive CI. | Add `--ip <your-IP>` to `prontaro forward`. |
| CI step hangs after migration finishes | Background `prontaro forward` kept stdout/stderr open. | Add `trap ’kill “$FWD_PID” 2>/dev/null |
| Database TLS hostname mismatch on `127.0.0.1` | Driver enforces `sslmode=verify-full` against the production hostname. | Use `sslmode=require` or follow the workarounds in the [`prontaro forward`](https://prontaro.com/docs/outbound/forward.md) guide. |

For `407`, `403`, and other proxy or CLI codes, see [error codes](https://prontaro.com/docs/cli/errors.md) and [HTTP & SOCKS5 proxy](https://prontaro.com/docs/outbound/proxy.md).

## Next steps

- [Local port forwarding (`prontaro forward`)](https://prontaro.com/docs/outbound/forward.md) — outbound TCP connections to allowlisted databases and SSH servers from your dedicated IPv4.
- [Install `prontaro` CLI on Linux](https://prontaro.com/docs/cli/linux.md) — download the static binary and verify SHA256 checksums in CI pipelines.
- [HTTP & SOCKS5 proxy](https://prontaro.com/docs/outbound/proxy.md) — proxy credentials, allowed target rules, and credential rotation.
- [Static IP in GitLab CI/CD](https://prontaro.com/docs/integrations/gitlab-ci.md) — the same proxy and `prontaro forward` patterns for GitLab Shared Runners.
- [Diagnostics and error codes](https://prontaro.com/docs/cli/errors.md) — troubleshooting `407`, `403`, `client_key_invalid`, and running `prontaro doctor`.
