Skip to content

Commit

Permalink
From buildlog it looks like the commit sha is also accessible from GI…
Browse files Browse the repository at this point in the history
…THUB_SHA. Lets try this, for making it more easy.
  • Loading branch information
Lars Gohr committed Aug 22, 2019
1 parent 3730249 commit e541342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
7 changes: 5 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
function cleanEnvironment() {
unset INPUT_SNAPSHOT
unset INPUT_DOCKERFILE
unset GITHUB_SHA
}

function itPushesMasterBranchToLatest() {
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit e541342

Please sign in to comment.