GitHub PR Integration
Set Up a Webhook
- Add a webhook to your repo
- Payload URL is:
- Content type:
- Add a "Secret" (can be anything). Remember it, as we'll need to pass it to our Docker container.
- Enable "Check Suites", "Check runs" and "Pull Requests" as the events that trigger the webhook.
Generate Access token
- Your installation of Nx Cloud will need permission to post comments on your Pull Requests
- Follow these instructions
- Make sure you select "repo" as a scope
- After you generate the token, make sure to copy and store it. We'll add it to your installation of Nx Cloud in a bit.
Optional - Configure Self-Hosted GitHub Instances
- If you are running a self-hosted edition of GitHub, you'll need to tell your installation of Nx Cloud where to make requests to
- Your GitHub API URL should look like this:
https://custom-github-host.com(without a trailing slash)
- Keep a note of it, as we'll use it to configure your installation of Nx Cloud ☝️
- Optionally, you can try the above URL in the browser to see if it finds the API.
- Note if you use public GitHub, this step is not required. You also don't need to provision the
GITHUB_API_URLenv variable when creating a container.
Configure Nx Cloud Installation
1image: 2 tag: 'latest' 3 4nxCloudAppURL: 'https://nx-cloud.myorg.com' 5 6github: 7 pr: 8 enabled: true 9 # apiUrl: '' uncomment when using github enterprise 10 11secret: 12 name: 'cloudsecret' 13 nxCloudMongoServerEndpoint: 'NX_CLOUD_MONGO_SERVER_ENDPOINT' 14 githubWebhookSecret: 'GITHUB_WEBHOOK_SECRET' 15 githubAuthToken: 'GITHUB_AUTH_TOKEN' 16
Note that the secret must contain
GITHUB_AUTH_TOKEN ( see Nx Cloud Helm Charts for more context).
Not using Helm:
Provide the following env variables to the
GITHUB_WEBHOOK_SECRETset to the secret you provisioned
GITHUB_AUTH_TOKENset to the token generated for you
GITHUB_API_URLset to the URL of your github installation
If you are running Nx Cloud as a single container, the three env vars should be provisioned for that container.
Optional - Configure
Nx Cloud uses the
accessToken property from nx.json to find a workspace for a given GitHub repository. If it isn't possible to set
accessToken, you can also pass
NX_CLOUD_INTEGRATION_DEFAULT_WORKSPACE_ID env variable to the container. This value will be used when the
accessToken property is missing. You can find the id of your workspace in the URL.