-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ce308c
commit a2daaf2
Showing
3 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
. "${BASH_SOURCE%/*}/utils.sh" | ||
|
||
translateDockerTag | ||
|
||
for container_path in ${BASH_SOURCE%/*}/../containers/default/* ; do | ||
|
||
container_name="chrisnharvey/magiclamp-$(basename $container_path)" | ||
|
||
BUILD_TAGS="" | ||
|
||
for TAG in ${TAGS} | ||
do | ||
BUILD_TAGS="${BUILD_TAGS}-t ${container_name}:${TAG} " | ||
done | ||
|
||
docker build ${BUILD_TAGS} ${container_path} | ||
|
||
for TAG in ${TAGS} | ||
do | ||
docker push "${container_name}:${TAG}" | ||
done | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# The following was taken from great work by Lars (elgohr) | ||
# Copyright (c) 2019 Lars | ||
# https://github.com/elgohr/Publish-Docker-Github-Action | ||
|
||
function translateDockerTag() { | ||
|
||
local BRANCH=$(echo ${GITHUB_REF} | sed -e "s/refs\/heads\///g" | sed -e "s/\//-/g") | ||
|
||
if isOnMaster; then | ||
|
||
TAGS="latest" | ||
|
||
elif isGitTag && isSemver "${GITHUB_REF}"; then | ||
|
||
TAGS=$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g" | sed -E "s/v?([0-9]+)\.([0-9+])\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?/\1.\2.\3\4 \1.\2\4 \1\4/g") | ||
|
||
elif isGitTag; then | ||
|
||
TAGS="latest" | ||
|
||
elif isPullRequest; then | ||
|
||
TAGS="${GITHUB_SHA}" | ||
|
||
else | ||
|
||
TAGS="${BRANCH}-dev" | ||
|
||
fi; | ||
|
||
} | ||
|
||
|
||
function isSemver() { | ||
|
||
echo "${1}" | grep -Eq '^refs/tags/v?([0-9]+)\.([0-9+])\.([0-9]+)(-[a-zA-Z]+(\.[0-9]+)?)?$' | ||
|
||
} | ||
|
||
|
||
function isOnMaster() { | ||
|
||
[ "${BRANCH}" = "master" ] | ||
|
||
} | ||
|
||
|
||
|
||
function isGitTag() { | ||
|
||
[ $(echo "${GITHUB_REF}" | sed -e "s/refs\/tags\///g") != "${GITHUB_REF}" ] | ||
|
||
} | ||
|
||
|
||
|
||
function isPullRequest() { | ||
|
||
[ $(echo "${GITHUB_REF}" | sed -e "s/refs\/pull\///g") != "${GITHUB_REF}" ] | ||
|
||
} |