mirror of
https://github.com/docker/metadata-action.git
synced 2026-11-16 23:15:02 +08:00
add commit count expression for Git context
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
8e671d84a3
commit
3b768d063f
5 changed files with 83 additions and 0 deletions
21
README.md
21
README.md
|
|
@ -46,6 +46,7 @@ ___
|
|||
* [`{{is_default_branch}}`](#is_default_branch)
|
||||
* [`{{is_not_default_branch}}`](#is_not_default_branch)
|
||||
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
|
||||
* [`{{commit_count}}`](#commit_count)
|
||||
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
|
||||
* [Major version zero](#major-version-zero)
|
||||
* [JSON output object](#json-output-object)
|
||||
|
|
@ -908,6 +909,26 @@ Default `tz` is UTC.
|
|||
| `{{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
|
||||
| `{{date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |
|
||||
|
||||
#### `{{commit_count}}`
|
||||
|
||||
Returns the number of commits reachable from `HEAD` in the selected Git checkout,
|
||||
using `git rev-list --count HEAD`. Requires `context: git` or `context: git:<path>`;
|
||||
using this expression with workflow context produces an error.
|
||||
|
||||
Shallow checkouts count only the available history. Use `fetch-depth: 0` to fetch
|
||||
the full history when you need the complete count:
|
||||
|
||||
```yaml
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: docker/metadata-action@v6
|
||||
with:
|
||||
context: git
|
||||
images: name/app
|
||||
tags: type=raw,value=rev-{{commit_count}}
|
||||
```
|
||||
|
||||
#### `{{commit_date '<format>' tz='<timezone>'}}`
|
||||
|
||||
Returns the date when the current git commit is committed, rendered by its
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue