Connect a source

Let Wardn read manifests from a GitHub repository or any git repository, and see how a push reaches a deployment.

A source is where manifests come from: a git repository and a directory inside it, or a Helm chart in an OCI registry. An app is built on a source and says how to render it; a deployment puts the app somewhere. Sources and apps explains the model. This page covers how Wardn reaches your repository and how it learns that something was pushed.

There are two ways to connect git:

The GitHub AppAny git repository
Private repositoriesYes, the ones each installation coversPublic repositories only (see Credentials)
How a push arrivesA push webhook, at once; a one-minute check as a fallbackThe one-minute check
Pull request previewsYesNo
Branch protection, for the protected-branch guardrailReported by GitHubUnknown
Commit status on previewsYesNo

Connect GitHub

The GitHub App is the way to connect private repositories on GitHub. A Wardn administrator creates the App once for the whole installation (GitHub App); on Wardn's managed service it already exists. After that, anyone with integration:manage installs it on their GitHub account or organization:

  1. In the web app, open Settings › Integrations and choose GitHub, then Connect GitHub.
  2. GitHub asks which account to install on and which repositories the App may read. Choose and confirm.
  3. GitHub sends you back to Wardn, which records the installation and the repositories it covers. The installation then belongs to your Wardn organization; an installation belongs to one organization only.

If the page says the server is not set up as a GitHub App, the person who runs Wardn has not created the App yet. GitHub covers the App's permissions, commit statuses and how to change which repositories an installation covers.

A source reads through an installation when its credentials are github-app:<installation id>. The installation id is the number at the end of the installation's settings page on GitHub (https://github.com/settings/installations/<id>, or under the organization's settings), and GET /api/v1/github/installations returns each installation with its credentialsRef ready to copy.

Any other git repository

Without the App, Wardn reads a repository with plain git. This works for any public repository on any host.

URL formExample
https://host/repohttps://gitlab.example.com/shop/web.git
ssh://host/repossh://[email protected]/shop/web.git
user@host:repo[email protected]:shop/web.git
git://host/repogit://git.example.com/shop/web.git

A URL never holds a password: one that does is refused. Plain http:// is refused too, because the repository and any token would travel unencrypted; a self-hosted server can allow it for development with WARDN_GIT_ALLOW_INSECURE_HTTP.

Credentials

credentialsRef is either a GitHub App installation (github-app:<id>) or the name of a secret in the server's secret store, which holds a token, a username and password, or an SSH key. This release has no screen or API for adding secrets to that store, so in practice a private repository needs the GitHub App. Leave Credentials empty for a public repository.

Create a source

You do not create a source on its own in the web app. The New app form (/apps/new) has a Source section: choose an existing source, or A new repository and fill it in. The source is created with the app. See Apps.

Field in the formAPI fieldMeaning
KindkindGit repository (git) or OCI artifact (oci).
Repository URL or OCI referenceurlA git URL as above, or oci://host/path for a chart. At most 2048 characters.
PathpathThe directory inside the repository that holds the manifests, the chart or the kustomization. Relative, without ..; empty for the root. Not used for OCI.
CredentialscredentialsRefSee Credentials. Empty for none.
Source namename1 to 63 characters. Defaults to the app's name in the form.

With the API:

api() { curl -fsS -H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' "$@"; }

api -X POST "$WARDN_API_URL/api/v1/sources" -d '{
  "name": "shop",
  "kind": "git",
  "url": "https://github.com/example/shop",
  "path": "deploy/web",
  "credentialsRef": "github-app:51234567"
}'

Creating, changing and deleting a source needs app:create; reading one needs app:read. A source that an app still uses cannot be deleted.

A source's page (from the GitHub integration's Source repos list) shows its Connection and, under Deployments, every deployment built from it with the newest commit its branch was seen at and its newest render. GET /api/v1/sources/{sourceId}/deployments returns the same.

How a push reaches a deployment

A deployment whose snapshots arrive from a branch follows that branch for each of its apps. Wardn learns that the branch moved in two ways, and both end in the same step.

  1. The webhook. When the GitHub App is installed on the repository, GitHub sends Wardn a push event within seconds of the push. Wardn checks the event's signature against the App's webhook secret and accepts each delivery once.
  2. The one-minute check. Every tracked branch is also looked at about once a minute (WARDN_SYNC_POLL_INTERVAL, default 1m, plus a small spread so branches added together are not all checked at once). This catches a webhook that never came, and it is the only trigger for repositories without the App.
  3. The look at the branch. Either way, Wardn then asks the repository where the branch points now, rather than trusting the event. If it has already rendered that commit, nothing happens. Otherwise it renders one snapshot of the deployment with that app at the new commit.

So ten pushes in a second become one render of the newest commit, a redelivered webhook changes nothing, and a missed webhook only delays a deploy by a minute. Renders of one deployment run one at a time, in order. What happens to the snapshot next (applied, held, or waiting for a guardrail) is in Sync and arrival.

Each snapshot records where it came from: repository, branch, commit, who pushed, the pull request if any, and whether the host reported the branch as protected.

An OCI source can be registered, but this release has nothing that renders it: a webhook and the one-minute check watch git only, so a deployment on a chart source never receives a snapshot. Use a git directory for charts you want deployed. See Helm charts.

When a push does not deploy

CheckWhere
The deployment takes snapshots from a branch, and it is the branch you pushed to.The deployment's Settings tab, Snapshots arrive and Branch; or the app's own Branch on its Settings tab.
The deployment is not set to observe only. An observing deployment renders and compares but never applies.Settings, Observe only.
A render ran. A render that fails (the chart does not render, an image tag cannot be resolved) makes no snapshot.The deployment stays on its last snapshot; the source's page shows the newest commit seen and the newest render.
The snapshot was not held.The Snapshots tab. See Held snapshots.
The webhook arrived.Settings › Integrations › GitHub, Recent deliveries. Without it, the push still arrives within a minute.

One repository, several apps

A source is a repository and a directory, so a repository that holds several things becomes several sources, or one source per directory. Each app then renders its own directory, and a push to the repository starts a render for every deployment whose app reads that repository and tracks the branch pushed to.

README.md

Here deploy/web is the Path of a Helm app and deploy/worker the Path of a plain-manifest app, both on the repository https://github.com/example/shop. The two sources can share the repository URL and differ only in Path and Source name. How a directory is read depends on the app's render type: see Apps.

A deployment can also hold several apps at once; its one snapshot then covers all of them. See Apps.

Which events Wardn reads

Wardn acts on two GitHub events and drops every other kind.

EventWhat it does
pushStarts a look at the pushed branch for every deployment that tracks it. A push that deletes a branch, or to a branch nobody tracks, does nothing.
pull_requestopened, synchronize and reopened build a preview; closed removes it; labeled and unlabeled allow or stop the preview of a pull request from a fork. Other actions are ignored.

A push is matched to your sources by the repository's owner/name, ignoring case, the .git suffix and whether the source URL uses https or ssh. So the source [email protected]:example/shop.git receives the push of Example/Shop.

Next

Related: Sources and apps, Sync and arrival, API.

On this page