mirror of
https://github.com/docker/build-push-action.git
synced 2024-11-15 16:33:50 +08:00
docs: example to sanitize tags with metadata-action
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
96daefdf52
commit
0732bea0f8
@ -100,7 +100,25 @@ or a cache reference:
|
|||||||
```
|
```
|
||||||
|
|
||||||
To fix this issue you can use our [metadata action](https://github.com/docker/metadata-action)
|
To fix this issue you can use our [metadata action](https://github.com/docker/metadata-action)
|
||||||
to generate sanitized tags, or a dedicated step to sanitize the slug:
|
to generate sanitized tags:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v3
|
||||||
|
with:
|
||||||
|
images: ghcr.io/${{ github.repository }}
|
||||||
|
tags: latest
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Or a dedicated step to sanitize the slug:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Sanitize repo slug
|
- name: Sanitize repo slug
|
||||||
@ -108,7 +126,7 @@ to generate sanitized tags, or a dedicated step to sanitize the slug:
|
|||||||
id: repo_slug
|
id: repo_slug
|
||||||
with:
|
with:
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
script: return '${{ github.repository }}'.toLowerCase()
|
script: return 'ghcr.io/${{ github.repository }}'.toLowerCase()
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
|
Loading…
Reference in New Issue
Block a user