mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
Add tag names
This commit is contained in:
12
README.md
12
README.md
@@ -116,3 +116,15 @@ with:
|
|||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
cache: true
|
cache: true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### tag_names
|
||||||
|
Use `tag_names` when you want to push tags/release by their git name (e.g. `refs/tags/MY_TAG_NAME`).
|
||||||
|
> CAUTION: Images produced by this feature can be override by branches with the same name - without a way to restore.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
with:
|
||||||
|
name: myDocker/repository
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
tag_names: true
|
||||||
|
```
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ inputs:
|
|||||||
cache:
|
cache:
|
||||||
description: 'Use cache when you have big images, that you would only like to build partially'
|
description: 'Use cache when you have big images, that you would only like to build partially'
|
||||||
required: false
|
required: false
|
||||||
|
tag_names:
|
||||||
|
description: 'Use tag_names when you want to push tags/release by their git name'
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
tag:
|
tag:
|
||||||
description: 'Is the tag, which was pushed'
|
description: 'Is the tag, which was pushed'
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ function translateDockerTag() {
|
|||||||
INPUT_NAME=$(echo ${INPUT_NAME} | cut -d':' -f1)
|
INPUT_NAME=$(echo ${INPUT_NAME} | cut -d':' -f1)
|
||||||
elif isOnMaster; then
|
elif isOnMaster; then
|
||||||
TAG="latest"
|
TAG="latest"
|
||||||
|
elif isGitTag && uses "${INPUT_TAG_NAMES}"; then
|
||||||
|
TAG=$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g")
|
||||||
elif isGitTag; then
|
elif isGitTag; then
|
||||||
TAG="latest"
|
TAG="latest"
|
||||||
elif isPullRequest; then
|
elif isPullRequest; then
|
||||||
|
|||||||
17
test.bats
17
test.bats
@@ -8,6 +8,7 @@ setup(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
|
unset INPUT_TAG_NAMES
|
||||||
unset INPUT_SNAPSHOT
|
unset INPUT_SNAPSHOT
|
||||||
unset INPUT_DOCKERFILE
|
unset INPUT_DOCKERFILE
|
||||||
unset INPUT_REGISTRY
|
unset INPUT_REGISTRY
|
||||||
@@ -77,6 +78,22 @@ Called /usr/local/bin/docker logout"
|
|||||||
[ "$output" = "$expected" ]
|
[ "$output" = "$expected" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "with tag names it pushes tags using the name" {
|
||||||
|
export GITHUB_REF='refs/tags/myRelease'
|
||||||
|
export INPUT_TAG_NAMES=true
|
||||||
|
|
||||||
|
run /entrypoint.sh
|
||||||
|
|
||||||
|
local expected="
|
||||||
|
Called /usr/local/bin/docker login -u USERNAME --password-stdin
|
||||||
|
Called /usr/local/bin/docker build -t my/repository:myRelease .
|
||||||
|
Called /usr/local/bin/docker push my/repository:myRelease
|
||||||
|
::set-output name=tag::myRelease
|
||||||
|
Called /usr/local/bin/docker logout"
|
||||||
|
echo $output
|
||||||
|
[ "$output" = "$expected" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "it pushes specific Dockerfile to latest" {
|
@test "it pushes specific Dockerfile to latest" {
|
||||||
export INPUT_DOCKERFILE='MyDockerFileName'
|
export INPUT_DOCKERFILE='MyDockerFileName'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user