GitHub App

Create the GitHub App for your Wardn install and give the server its settings.

Wardn connects to GitHub through a GitHub App that belongs to your install. You create it once, as the person who runs Wardn. After that, people in each Wardn organization install it on their own GitHub accounts from the web app, which GitHub describes.

The App is optional. Without it, Wardn reads public repositories over https:// and repositories it has credentials for, and looks at each tracked branch once a minute. With it you get:

  • private repositories, with access limited to the ones each installation chooses;
  • push and pull request webhooks, so a push starts a render at once instead of within a minute;
  • pull request previews, with a commit status on the pull request and, optionally, a GitHub deployment;
  • the branch protection status that the production protected-branch guardrail checks.

Create the App

Open the form

In GitHub, go to the settings of the account or organization that should own the App, then Developer settings, GitHub Apps, New GitHub App. The owner only manages the App; any account can install it later.

Fill in the addresses

Use your Wardn's public address, the same as publicUrl in the charts:

FieldValue
Homepage URLhttps://wardn.example.com
Setup URLhttps://wardn.example.com/sources/github/setup. Tick Redirect on update.
Request user authorization (OAuth) during installationTicked, so only someone who can see an installation can claim it.
Webhook URLhttps://wardn.example.com/api/v1/webhooks/github. Webhook Active.
Webhook secretA long random value. Keep it; the server needs it.

Generate a webhook secret with:

head -c 32 /dev/urandom | base64 | tr -d '\n=+/'

Choose permissions and events

Repository permissionAccessWhy
ContentsReadRead manifests and charts.
MetadataReadRequired by GitHub for every App.
Pull requestsRead and writeBuild pull request previews and keep one comment on each. Without write access previews still work, only without the comment.
Commit statusesRead and writePost the wardn/preview status on a pull request's commit.
DeploymentsRead and writeOptional. Gives each preview a GitHub deployment and its View deployment button.

Subscribe to the Push and Pull request events.

Without the Deployments permission, previews still work and keep their commit status; Wardn logs the refusal once per installation. If you add the permission later, each existing installation must accept it in GitHub before it applies.

Create it and make a private key

After Create GitHub App, note the App ID and the App's URL name (the slug, as in github.com/apps/<slug>). Then, under Private keys, choose Generate a private key. GitHub downloads a .pem file. It is the App's identity: store it like a password.

Give the server the App's settings

The server needs four settings. They are all or nothing: with an App id set, the slug, one form of the key and the webhook secret are required, and with no App id the others must be unset. A mismatch stops the server at start with a message naming the problem.

SettingValue
WARDN_GITHUB_APP_IDThe App ID, a number.
WARDN_GITHUB_APP_SLUGThe slug.
WARDN_GITHUB_APP_PRIVATE_KEY or WARDN_GITHUB_APP_PRIVATE_KEY_FILEThe .pem contents, or a path to the file. Set one, not both. In a one-line value, write line breaks as \n.
WARDN_GITHUB_WEBHOOK_SECRETThe webhook secret.

Also set WARDN_PUBLIC_URL to your Wardn's address. Wardn uses it for the links it puts in GitHub, such as the Details link on a preview's commit status. Without it, those links are left out.

Put the secrets in a Secret:

kubectl -n wardn create secret generic wardn-github \
  --from-file=private-key=my-wardn.private-key.pem \
  --from-literal=webhook-secret='...'

Then pass the settings with server.extraEnv. The charts have no GitHub values of their own.

values.yaml
server:
  extraEnv:
    - {name: WARDN_GITHUB_APP_ID, value: "123456"}
    - {name: WARDN_GITHUB_APP_SLUG, value: my-wardn}
    - {name: WARDN_PUBLIC_URL, value: https://wardn.example.com}
    - name: WARDN_GITHUB_APP_PRIVATE_KEY
      valueFrom: {secretKeyRef: {name: wardn-github, key: private-key}}
    - name: WARDN_GITHUB_WEBHOOK_SECRET
      valueFrom: {secretKeyRef: {name: wardn-github, key: webhook-secret}}
helm upgrade wardn oci://ghcr.io/future-pirate-king/charts/wardn-standard -n wardn --values values.yaml

GitHub Enterprise Server

Create the App on your GitHub Enterprise Server the same way, and point Wardn at it:

SettingExample
WARDN_GITHUB_API_URLhttps://github.example.com/api/v3
WARDN_GITHUB_WEB_URLhttps://github.example.com

The web address is the one repository URLs and the install link are under. Both default to github.com.

Check that it works

  1. In the web app, open the integrations page and connect GitHub. If it says GitHub is not configured, the server did not get an App id: check the settings and restart.
  2. Install the App on an account and choose a repository. GitHub sends you back to Wardn, which records the installation for your organization.
  3. In the App's settings on GitHub, Advanced lists recent webhook deliveries. A push to a tracked branch should show a delivery answered with 2xx.

A delivery whose signature does not match the webhook secret is refused. A repeated delivery id is answered 409 and not processed twice. Events of other kinds, and events from installations Wardn does not know, are accepted and dropped.

Rotate the key or the secret

  • Private key. Generate a new key in GitHub, update the Secret or file, restart the server, then delete the old key in GitHub. GitHub accepts either key until you delete one.
  • Webhook secret. Change it in GitHub and in the server's setting together. Deliveries sent while the two differ are refused; the one-minute poll covers pushes in that gap.

Next

On this page