Skip to content

Commit 13c14d9

Browse files
authored
Proxy Danger requests through a proxy service (#10395)
This PR updates Danger to proxy its requests to GitHub through a proxy service. ## Motivation Currently Danger is not able to run on PRs opened from forks of Zed. This is due to GitHub Actions' security policies. Forks are not able to see any of the repository secrets, and the built-in `secrets.GITHUB_TOKEN` has its permissions [restricted](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token) to only reads when running on forks. I asked around on the Danger repo, and some big projects (DefinitelyTyped) are working around this by using a publicly-listed (although slightly obfuscated) token: danger/danger-js#918 (comment). While this approach is _probably_ okay given the limited scope and permissions of the GitHub token, I would still prefer a solution that avoids disclosing the token at all. ## Explanation I ended up writing a small proxy service, [Danger Proxy](https://github.com/maxdeviant/danger-proxy), that can be used to provide Danger with the ability to make authenticated GitHub requests, but without disclosing the token. From the README: > Danger Proxy will: > > - Proxy all requests to `/github/*` to the GitHub API. The provided GitHub API token will be used for authentication. > - Restrict requests to the list of repositories specified in the `ALLOWED_REPOS` environment variable. > - Restrict requests to the subset of the GitHub API that Danger requires. I have an instance of this service deployed to [danger-proxy.fly.dev](https://danger-proxy.fly.dev/). Release Notes: - N/A
1 parent 3b68665 commit 13c14d9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/danger.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ jobs:
3232
- name: Run Danger
3333
run: pnpm run --dir script/danger danger ci
3434
env:
35-
GITHUB_TOKEN: ${{ github.token }}
35+
# This GitHub token is not used, but the value needs to be here to prevent
36+
# Danger from throwing an error.
37+
GITHUB_TOKEN: "not_a_real_token"
38+
# All requests are instead proxied through an instance of
39+
# https://github.com/maxdeviant/danger-proxy that allows Danger to securely
40+
# authenticate with GitHub while still being able to run on PRs from forks.
41+
DANGER_GITHUB_API_BASE_URL: "https://danger-proxy.fly.dev/github"

0 commit comments

Comments
 (0)