Skip to content

Add parameter to add additional docker tags #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,23 @@ steps:
- my-custom-plugin#v1.0.0:
```

### Specifying tags to apply to the pushed Docker image

The image is tagged with the cache key and`latest`.

By specifying the `tags` parameter you can specify your own set of tags to apply to the image:

```yaml
steps:
- command: echo wow
plugins:
- seek-oss/docker-ecr-cache#v2.0.0:
tags:
- build-${BUILDKITE_BUILD_NUMBER}
```

These tags are applied *each time the plugin runs*, whether the image is newly built or already exists and was pulled.

### AWS ECR specific configuration

#### Specifying an ECR repository name
Expand Down
11 changes: 11 additions & 0 deletions hooks/pre-command
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ if ! docker pull "${image}:${tag}"; then
docker push "${image}:latest"
fi || echo "Not found"

results=()
read_list_property 'TAGS'
if [ "${#result[*]}" != "0" ]; then
for extra_tag in ${result[@]+"${result[@]}"}; do
echo "--- Pushing extra tags"
echo " - ${extra_tag}"
docker tag "${image}:${tag}" "${image}:${extra_tag}"
docker push "${image}:${extra_tag}"
done
fi

# Support using https://github.com/buildkite-plugins/docker-buildkite-plugin without an image by default
export ${export_env_variable}="${image}:${tag}"

Expand Down
2 changes: 2 additions & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ configuration:
type: string
region:
type: string
tags:
type: [array, string]
required: []