Git integration
Forge starts runs when your code changes: a push, a tag or a pull request in a linked repository fires a Git trigger, the run gets the commit checked out, and the result goes back to the commit as a check or status. Setting it up takes three steps: an organization owner connects the Git host, a project links repositories, and someone adds triggers.
Connect a Git host
Connections belong to the organization, on its Git page. Connecting needs the git:manage
permission. Tokens are stored encrypted and never shown again.
| Host | How Forge connects |
|---|---|
| GitHub | Install the GitHub App on an account and choose its repositories, or Connect an existing installation. |
| GitLab (gitlab.com or self-managed) | The Instance URL and an Access token with the api scope: a group or project access token, or a bot user's personal token. |
| Gitea and Forgejo | The Instance URL and a bot user's access token with the scopes write:repository and read:user. The bot needs admin access to the repositories you link. |
| Bitbucket Cloud | The Workspace ID (acme for bitbucket.org/acme) and an access token with the scopes for repositories, pull requests and webhooks, with admin access to the repositories you link. |
| Other Git servers | A name and the Base URL repositories are cloned from, like https://git.example.com. |
Connecting the same GitLab token user, Gitea bot or Bitbucket workspace again replaces its token, for example when it expires. The Git page warns when a GitLab token expires soon. Disconnect removes the webhooks Forge added and the projects' links to that host's repositories.
Link repositories
On the project's Repositories page, choose Choose a repository, pick one and choose Link. Forge adds its webhook to the repository. Unlink removes it.
- GitLab offers the projects the token user has Maintainer access to.
- Gitea, Forgejo and Bitbucket: the host's token can administer the repository, so it is never given to a run. A private repository is cloned with a Checkout secret: a project secret holding a read-only token. Without one, Forge clones without credentials, which works for a public repository. See secrets and variables.
- Other Git servers: fill in A repository on another Git server with its Path (like
group/app.git), Default branch and, for a private repository, a Checkout secret and Checkout username. Forge then shows the link's Webhook URL and Signing secret. The secret is shown only once. New signing secret replaces it, and the old one stops working at once.
Events from other Git servers
A server Forge can't call sends its events to the webhook URL itself. On a server with a
post-receive hook, install the forge command line and let it send them:
#!/bin/sh
# hooks/post-receive in the bare repository
export FORGE_HOOK_URL=https://forge.example.com/hooks/generic/... # the link's webhook URL
export FORGE_HOOK_SECRET="$(cat /etc/forge/app.secret)" # its signing secret
exec forge hook post-receive
It sends one event per pushed branch or tag, with the head commit's message and the changed
files. forge hook send sends one event by hand, for example
forge hook send --pr 12 --base main --head feature --sha "$SHA" --fork. The secret is read only
from the environment, never from a flag.
Other servers get no commit statuses, no run files and no manual runs on a branch, because Forge can't call them. Use the project's webhooks to report results back.
Add a trigger
A trigger runs as one of the project's service accounts.
Creating or changing one needs trigger:write and the right to grant that account's role.
- From a template's page, New Git trigger runs that template's latest version.
- From a saved flow's page, it runs that flow. See flows.
- On the project's Git triggers page, New file trigger runs a file from the repository (below).
Events
- Push: commits pushed to a branch.
- Tag: a tag pushed.
- Pull request: opened, updated or reopened (on GitLab, a merge request).
- Merge queue (GitHub only): the merge queue testing queued pull requests together.
Deleting a branch or tag never fires.
Filters
Each filter is a list of patterns, one per line. An empty list matches everything.
- Branches: the pushed branch, or a pull request's base branch, like
mainorrelease/**. - Tags: the pushed tag, like
v*. - Paths: the changed files, like
src/**and!src/docs/**.
* matches within a path segment, ** across segments and ? one character. A line starting
with ! excludes, and the last matching line wins. When the changed files can't all be known (a
new branch, or a very large push or pull request), the path filter passes.
More settings
- Older runs for the same branch, tag or pull request: Keep them running, or Cancel them when a new run starts.
- Comment on pull requests: keep one comment on each pull request with the latest run's result, updated by each run.
- Env:
NAME=valuelines for the trigger's runs. They override the template's env, except its locked names; a run file's ownenvoverrides them.FORGE_GIT_*names are set from the event. - Run on a branch or tag, on the trigger's page, starts a run now on the commit a branch or tag points to, also while the trigger is disabled. The filters don't apply.
Skip markers
A push or pull request whose head commit message has [skip ci], [ci skip], [no ci],
[skip forge] or [forge skip] starts nothing. The trigger's history records it as skipped. Turn
this off with Honor skip markers in the project's General settings. On Gitea, Forgejo and
Bitbucket, the markers apply to pushes only.
What the run gets
The commit is cloned into /workspace before the run starts, with a short-lived read-only
credential the run's own processes never see. /workspace is the working directory unless the
spec sets working_dir. Set checkout: false to skip it, or give options:
checkout:
depth: 0 # the full history; default 1
submodules: recursive # false (default), true or recursive
lfs: true
path: /workspace/app
The run also gets the event as variables: FORGE_GIT_REPOSITORY, FORGE_GIT_EVENT,
FORGE_GIT_REF, FORGE_GIT_REF_NAME, FORGE_GIT_SHA, FORGE_GIT_ACTOR, and for pull requests
FORGE_GIT_PR_NUMBER, FORGE_GIT_BASE_REF and FORGE_GIT_HEAD_REF.
Run files and flow files
A file trigger has no template. It reads a .yaml or .yml file under .forge/ (default
.forge/run.yaml) at each event's commit, so the repository holds its own run definition. A pull
request's run uses the file as it is in the pull request.
version: 1
name: tests
image: golang:1.24
commands:
- name: test
run: go test ./...
secrets:
NPM_TOKEN: {}
retry: { max_attempts: 2 }
A run file has the run spec's fields plus name and retry;
version: 1 is required. Unknown fields are refused, with their line. A file with stages is a
flow file and starts a flow run instead.
Anyone who can push can change the file, so the trigger lists what it may use: Allowed secrets, Allowed registries, Allowed environments, Allowed repositories and Allowed OIDC token audiences. The file may name only those, and an empty list allows none. Secrets restricted to templates are never available to file runs.
A missing or invalid file starts nothing: the trigger's history has the reason, and the commit gets a failed check. Push a fixed file to try again.
Checks and statuses
Each run of a trigger shows on its commit, named after the trigger, with a link to the run page. The run's output is never sent.
- GitHub: a check run, from queued to its result. GitHub's Re-run starts the run again on the same commit.
- GitLab, Gitea, Forgejo and Bitbucket: a commit status named
PROJECT/TRIGGER. Re-run in Forge.
A flow run is reported as one check with a table of its steps.
Pull requests from forks
A fork's pull request runs code you haven't reviewed, so its runs get no secrets; the run page
lists what was withheld. Unless the author can push to the repository, the run waits as
awaiting approval, and the commit shows "Waiting for approval". Someone with git:approve
(developers and up) reviews the changes and chooses Approve and run on the run page. That
approves the commit: its waiting runs start, and later runs of the same commit don't wait. Each
new push needs a new approval. Cancelling rejects the run, and runs nobody approves are cancelled
after 7 days. From another Git server, a fork's run always waits.
Status badges
A status badge shows whether a template's, Git trigger's or saved flow's latest run passed: passing, failing, running or unknown. Cancelled runs don't count. In the project's settings, open Status badges, pick what the badge is of, optionally a branch, and a label of at most 40 characters. Copy its Markdown into your README:

Anyone with the address sees the badge without signing in, but it shows only its label and
status. Deleting a badge breaks its address. A badge can be up to a minute behind. Making and
deleting badges needs project:manage; a project has at most 50.