Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/test-github-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test GitHub proxy action

on:
pull_request:
paths:
- github-proxy/**
- .github/workflows/test-github-proxy.yml
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Node 24 (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: "24"
package-manager-cache: false
- name: Test proxy configuration and revocation
run: node --test github-proxy/action/action.test.js
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Shared GitHub Actions for Astral projects.

- [Simple token service](simple-token-service/): exchange GitHub Actions OIDC tokens
for scoped GitHub App installation tokens.
- [GitHub proxy](github-proxy/): configure Git pushes through a branch-scoped proxy
capability.
- [Key-value store](key-value-store/): share workflow state within a GitHub Actions
OIDC namespace.
- [Rust workspace cache](rust-workspace-cache/): cache workspace crates and prune
Expand Down
73 changes: 73 additions & 0 deletions github-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# GitHub proxy

Configure a Git remote to push through a GitHub proxy using an encrypted
capability for one repository, branch, and expected previous head. The action sets
a repository-scoped authorization header in the local Git configuration and
changes the remote's push URL.

Request the capability from a token service deployment that supports
`delivery: github-proxy`. Keep that exchange in a trusted setup job with
`id-token: write`, then pass the capability to a separate reusable workflow as an
explicitly declared secret. See the
[token service action](../simple-token-service/README.md#branch-scoped-proxy-delivery)
for the issuer inputs.

The receiving workflow can configure its remote as follows:

```yaml
on:
workflow_call:
secrets:
proxy_capability:
required: true

permissions:
contents: read

jobs:
agent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@<commit-sha>
with:
persist-credentials: false
- uses: astral-sh/github-actions/github-proxy@<commit-sha>
with:
proxy-url: ${{ vars.PROXY_API_URL }}
capability: ${{ secrets.proxy_capability }}
repository: example-org/example-repo
- run: git push origin HEAD:automation/fix-123
```

The push must match the repository, branch, and expected previous head authorized
by the capability. Keep `id-token: write` out of the receiving job: an applicable
service policy could otherwise let it request a raw installation token. Pass the
capability through the declared secret so GitHub masks it before logging action inputs; do not hand it off through
ordinary inputs, environment variables, shell interpolation, or `secrets: inherit`.

The issuing job leaves the capability output unmasked so GitHub can transfer it
between jobs. Treat it as a bearer credential: never print it or upload it as an
artifact. This action stores it in the checkout's `.git/config`; never archive or
upload `.git`. Use GitHub-hosted or isolated ephemeral runners.

Pin actions to full commit SHAs. Check out the repository before configuring the
proxy, and use `persist-credentials: false` so checkout does not install a separate
Git credential.

## Inputs

| Input | Description |
| ------------ | ---------------------------------------------------------------------------------- |
| `proxy-url` | Required HTTPS origin of the deployed GitHub proxy. |
| `capability` | Required encrypted capability from the token service, passed as a declared secret. |
| `repository` | Required target repository in `OWNER/REPO` form. |
| `remote` | Git remote to configure. Defaults to `origin`. |

## Outputs

| Output | Description |
| --------- | ------------------------------------------------------------------ |
| `git-url` | HTTPS push URL for the configured repository, without credentials. |

The post action attempts to revoke the underlying installation token when the job
finishes, including after a failed step. A failed revocation logs a warning.
27 changes: 27 additions & 0 deletions github-proxy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Configure a branch-scoped GitHub proxy
description: Configure Git to push through a short-lived, exact-branch GitHub proxy capability.

inputs:
proxy-url:
description: HTTPS origin of the deployed GitHub proxy.
required: true
capability:
description: Encrypted branch-scoped capability issued by the token service.
required: true
repository:
description: GitHub repository authorized by the capability, in OWNER/REPO form.
required: true
remote:
description: Git remote whose push URL should use the proxy.
required: false
default: origin

outputs:
git-url:
description: Credential-free HTTPS push URL for the configured repository.

runs:
using: node24
main: action/main.js
post: action/post.js
post-if: always()
Loading
Loading