mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
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:
@@ -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}
|
||||
|
||||
7
test.sh
7
test.sh
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user