mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-15 09:21:00 -04:00
Add option to specify a Dockerfile
This commit is contained in:
38
test.sh
38
test.sh
@@ -1,5 +1,10 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
function cleanEnvironment() {
|
||||
unset INPUT_snapshot
|
||||
unset INPUT_dockerfile
|
||||
}
|
||||
|
||||
function itPushesMasterBranchToLatest() {
|
||||
export GITHUB_REF='refs/heads/master'
|
||||
local result=$(exec /entrypoint.sh 'my/repository')
|
||||
@@ -36,6 +41,20 @@ Called mock with: push my/repository:latest"
|
||||
fi
|
||||
}
|
||||
|
||||
function itPushesSpecificDockerfileReleasesToLatest() {
|
||||
export GITHUB_REF='refs/tags/myRelease'
|
||||
export INPUT_dockerfile='MyDockerFileName'
|
||||
local result=$(exec /entrypoint.sh 'my/repository')
|
||||
local expected="Called mock with: build -f MyDockerFileName -t my/repository:latest .
|
||||
Called mock with: push my/repository:latest"
|
||||
if [ "$result" != "$expected" ]; then
|
||||
echo "Expected: $expected
|
||||
Got: $result"
|
||||
exit 1
|
||||
fi
|
||||
cleanEnvironment
|
||||
}
|
||||
|
||||
function itPushesBranchByShaInAddition() {
|
||||
export GITHUB_REF='refs/tags/myRelease'
|
||||
export INPUT_snapshot='true'
|
||||
@@ -48,9 +67,28 @@ Called mock with: push my/repository:COMMIT_SHA"
|
||||
Got: $result"
|
||||
exit 1
|
||||
fi
|
||||
cleanEnvironment
|
||||
}
|
||||
|
||||
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')
|
||||
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"
|
||||
if [ "$result" != "$expected" ]; then
|
||||
echo "Expected: $expected
|
||||
Got: $result"
|
||||
exit 1
|
||||
fi
|
||||
cleanEnvironment
|
||||
}
|
||||
|
||||
itPushesMasterBranchToLatest
|
||||
itPushesBranchAsNameOfTheBranch
|
||||
itPushesReleasesToLatest
|
||||
itPushesSpecificDockerfileReleasesToLatest
|
||||
itPushesBranchByShaInAddition
|
||||
itPushesBranchByShaInAdditionWithSpecificDockerfile
|
||||
|
||||
Reference in New Issue
Block a user