Git Commit
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
Description
The gitcommit resource works with commit hashes rather than versions (useful for pinning an action, a submodule, or a base image to an exact commit instead of a moving branch).
- source
Returns the latest commit hash of
branch, or of the repository’s currentHEADwhenbranchis unset.- condition
Checks that a commit exists in the repository (
hashwhen set, otherwise the source output).- target
Not supported - a target fails with
target not supported for the Git Commit resource. Updatecli commits through an scm, not through this resource.
Note | This resource is newer than the JSON schema bundled with the website, so the parameter table below may be empty until the schema is regenerated. The parameters are listed in full underneath. |
Parameters
| Name | Type | Description | Required |
|---|
| Name | Description |
|---|---|
| The repository to clone, e.g. |
| A local repository path to read instead of cloning. |
| Source only. The branch whose latest commit is returned. Defaults to the repository’s current |
| Condition only. The commit being checked. Defaults to the source output. |
| Limits how many commits are fetched. |
| Credentials for the HTTP protocol. |
Choosing the repository
Three things can say where the repository is, and they override each other in a fixed order, url, then path, then the scmid:
| Set | Result |
|---|---|
| The repository is cloned, overriding both |
| That local directory is used, overriding the attached scm. |
neither | The working directory of the |
Setting url or path alongside an scmid is allowed but logs a warning naming what was overridden, for example URL setting value "…" is overriding the scm configuration (value "…").
With none of the three, the run fails with a message that lists the options:
unknown Git working directory. Did you specify one of `spec.URL`, `scmid` or `spec.path`?Warning |
|
Example
Pin a dependency to the exact commit currently at the tip of main:
sources:
latestCommit:
name: Get the latest commit of updatecli/updatecli
kind: gitcommit
spec:
url: https://github.com/updatecli/updatecli.git
branch: main
targets:
pin:
name: Pin the action to that commit
kind: file
sourceid: latestCommit
spec:
file: .github/workflows/updatecli.yaml
matchpattern: 'updatecli/updatecli-action@([0-9a-f]{40})'
replacepattern: 'updatecli/updatecli-action@{{ source "latestCommit" }}'Links
The
gitbranchresource - to find a branch nameThe
gittagresource - to find a tag