Git Push

Commits the files of an event on top of a branch and pushes the commit. Works with any HTTPS Git host; SSH URLs are not supported.

The input event carries files, each {path, content} with paths relative to path. content is required; null deletes the file. An optional previous holds the content the change was prepared against (or null for a file that should not exist yet): when the branch holds something else, the push fails with a conflict instead of overwriting it. A file that already holds the new content passes, so a push repeated after it landed succeeds.

When the branch moved while the commit was being built, the push fails as moved and the task’s retry builds it again on the new tip, as long as every previous still holds. A change that leaves the tree as it is pushes nothing. Pushes from one task run one at a time, in no guaranteed order. A file keeps its executable bit when it is updated. A path that runs through an existing file, such as a.yaml/b.yaml when a.yaml is a file, is a conflict.

The output lists the text files under path; files that are not UTF-8 are left out.

Configuration

- git_push:
    name: commit
    repository_url: "{{env.GIT_REPOSITORY_URL}}"
    branch: main
    path: "configs/"
    credentials_path: /etc/git/credentials.json
    author:
      name: "{{event.data.author.name}}"
      email: "{{event.data.author.email}}"
    message: "{{event.data.title}}"

Fields

FieldTypeDefaultDescription
namestringrequiredTask name.
repository_urlstringrequiredGit repository URL. With credentials_path it must be HTTPS, or HTTP to a loopback host; SSH is not supported.
branchstringmainBranch to push to. Created on the first push to an empty repository; in a repository with other branches it must exist.
pathstringDirectory within the repository the file paths are relative to. Paths that leave it are rejected.
credentials_pathstringPath to credentials JSON file.
author.namestringrequiredCommit author name. Supports templating.
author.emailstringrequiredCommit author email. Supports templating.
committer.namestringauthor’sCommitter name. Supports templating.
committer.emailstringauthor’sCommitter email. Supports templating.
signing_key_pathstringPath to an unencrypted OpenSSH Ed25519 private key that signs each commit. See Signed commits.
messagestringrequiredCommit message. Supports templating.
timeoutduration120sTime budget for each request to the git server, including the pack upload, and for fetching the branch and building the commit.
connect_timeoutduration10sTCP/TLS connect timeout.
depends_onlistUpstream task names.
retryobjectRetry configuration. Conflicts, invalid paths, pushes the server rejects, and client errors (4xx other than 408 and 429) are not retried.

Input

{
  "files": [
    { "path": "settings/a.yaml", "content": "enabled: true", "previous": null },
    { "path": "nested/b.txt", "content": null }
  ]
}

Signed commits

With signing_key_path, each commit is signed the way git commit -S signs with gpg.format=ssh. Git hosts verify the signature against the committer’s account, and branches that require signed commits accept only verified ones. Set committer to the account that holds the key, and keep author as the person behind the change:

- git_push:
    name: commit
    repository_url: "{{env.GIT_REPOSITORY_URL}}"
    credentials_path: /etc/git/credentials.json
    signing_key_path: /etc/git/signing_key
    committer:
      name: "flowgen"
      email: "[email protected]"
    author:
      name: "{{event.data.author.name}}"
      email: "{{event.data.author.email}}"
    message: "{{event.data.title}}"

Create the key with ssh-keygen -t ed25519 -N "" -f signing_key, mount the private key at signing_key_path, and add signing_key.pub as a signing key to the committer’s account on the git host. The committer’s email must be a verified email of that account.

Output

FieldTypeDescription
commitstringThe branch tip after the push.
changedboolfalse when the files left the tree unchanged and nothing was pushed.
filesarrayEvery file under path at commit, as {path, content}. Feeds OCI Push directly.

Examples