From buildlog it looks like the commit sha is also accessible from GITHUB_SHA. Lets try this, for making it more easy.

This commit is contained in:
Lars Gohr
2019-08-22 07:23:55 +02:00
parent 3730249596
commit e541342d5d
2 changed files with 6 additions and 4 deletions

View File

@@ -21,8 +21,7 @@ fi
if [ "${INPUT_SNAPSHOT}" == "true" ]; then
SHA=$(env | grep ^github\\.sha= | cut -d= -f2-) # Thank you Github for using dots in variables
SHA_DOCKER_NAME="${DOCKER_REPOSITORY}:${SHA}"
SHA_DOCKER_NAME="${DOCKER_REPOSITORY}:${GITHUB_SHA}"
docker build $CUSTOMDOCKERFILE -t ${DOCKERNAME} -t ${SHA_DOCKER_NAME} .
docker push ${DOCKERNAME}
docker push ${SHA_DOCKER_NAME}

View File

@@ -3,6 +3,7 @@
function cleanEnvironment() {
unset INPUT_SNAPSHOT
unset INPUT_DOCKERFILE
unset GITHUB_SHA
}
function itPushesMasterBranchToLatest() {
@@ -58,7 +59,8 @@ Called mock with: push my/repository:latest"
function itPushesBranchByShaInAddition() {
export GITHUB_REF='refs/tags/myRelease'
export INPUT_SNAPSHOT='true'
local result=$(exec env 'github.sha'=COMMIT_SHA /entrypoint.sh 'my/repository')
export GITHUB_SHA='COMMIT_SHA'
local result=$(exec /entrypoint.sh 'my/repository')
local expected="Called mock with: build -t my/repository:latest -t my/repository:COMMIT_SHA .
Called mock with: push my/repository:latest
Called mock with: push my/repository:COMMIT_SHA"
@@ -74,7 +76,8 @@ function itPushesBranchByShaInAdditionWithSpecificDockerfile() {
export GITHUB_REF='refs/tags/myRelease'
export INPUT_SNAPSHOT='true'
export INPUT_DOCKERFILE='MyDockerFileName'
local result=$(exec env 'github.sha'=COMMIT_SHA /entrypoint.sh 'my/repository')
export GITHUB_SHA='COMMIT_SHA'
local result=$(exec /entrypoint.sh 'my/repository')
local expected="Called mock with: build -f MyDockerFileName -t my/repository:latest -t my/repository:COMMIT_SHA .
Called mock with: push my/repository:latest
Called mock with: push my/repository:COMMIT_SHA"