Skip to content

Commit

Permalink
update to use both set-env and set-output
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Oct 21, 2019
1 parent c116b1c commit 6267cfd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker-toughday
1 change: 1 addition & 0 deletions scripts/github/github_container_verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ echo "TEST_COMMAND:${TEST_COMMAND}"
echo "TEST:docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} bash -c 'echo \$(\${TEST_COMMAND} 2>&1) | grep -q -e ${TEST_COMMAND_VERIFY} && echo true || echo false'"
export CONTAINER_OUTPUT=$(docker run --env TEST_COMMAND ${IMAGE}:${IMAGE_VERSION} bash -c "echo \$(\${TEST_COMMAND} 2>&1) | grep -q -e \"${TEST_COMMAND_VERIFY}\" && echo true || echo false")
echo ::set-env name=CONTAINER_OUTPUT::$CONTAINER_OUTPUT
echo ::set-output name=CONTAINER_OUTPUT::$CONTAINER_OUTPUT
echo "CONTAINER_OUTPUT:${CONTAINER_OUTPUT}"
echo "TEST IF OUTPUT MATCHES EXPECTED"
if [[ "${CONTAINER_OUTPUT}" == "false" ]]; then
Expand Down
5 changes: 5 additions & 0 deletions scripts/github/github_get_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ fi
echo ">>> GET CONFIG FROM DOCKERFILE <<<"
export IMAGE_NAME=$(grep imagename= Dockerfile | sed -e 's/.*imagename="\(.*\)".*/\1/')
echo ::set-env name=IMAGE_NAME::${IMAGE_NAME}
echo ::set-output name=IMAGE_NAME::${IMAGE_NAME}
export TEST_COMMAND=$(grep test.command= Dockerfile | sed -e 's/.*test.command="\(.*\)".*/\1/')
echo ::set-env name=TEST_COMMAND::${TEST_COMMAND}
echo ::set-output name=TEST_COMMAND::${TEST_COMMAND}
export TEST_COMMAND_VERIFY=$(grep test.command.verify= Dockerfile | sed -e 's/.*test.command.verify="\(.*\)".*/\1/')
echo ::set-env name=TEST_COMMAND_VERIFY::${TEST_COMMAND_VERIFY}
echo ::set-output name=TEST_COMMAND_VERIFY::${TEST_COMMAND_VERIFY}
export IMAGE_VERSION=$(grep version= Dockerfile | sed -e 's/.*version="\(.*\)".*/\1/')
echo ::set-env name=IMAGE_VERSION::${IMAGE_VERSION}
echo ::set-output name=IMAGE_VERSION::${IMAGE_VERSION}
export IMAGE="${ORGANISATION_NAME}/${IMAGE_NAME}"
echo ::set-env name=IMAGE::${IMAGE}
echo ::set-output name=IMAGE::${IMAGE}
echo "IMAGE_NAME=${IMAGE_NAME}"
echo "IMAGE_VERSION=${IMAGE_VERSION}"
echo "TEST_COMMAND=${TEST_COMMAND}"
Expand Down
8 changes: 8 additions & 0 deletions scripts/github/github_get_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ echo "CURRENT_VERSION:${CURRENT_VERSION}"
declare -a CURRENT_VERSION_ARRAY="(${CURRENT_VERSION//./ })";
export SEMVER_MAJOR=${CURRENT_VERSION_ARRAY[0]};
echo ::set-env name=SEMVER_MAJOR::${SEMVER_MAJOR}
echo ::set-output name=SEMVER_MAJOR::${SEMVER_MAJOR}
export SEMVER_MINOR=${CURRENT_VERSION_ARRAY[1]};
echo ::set-env name=SEMVER_MINOR::${SEMVER_MINOR}
echo ::set-output name=SEMVER_MINOR::${SEMVER_MINOR}
export SEMVER_PATCH=${CURRENT_VERSION_ARRAY[2]};
echo ::set-env name=SEMVER_PATCH::${SEMVER_PATCH}
echo ::set-output name=SEMVER_PATCH::${SEMVER_PATCH}
export SEMVER_BUILD=${CURRENT_VERSION_ARRAY[-1]}
echo ::set-env name=SEMVER_BUILD::${SEMVER_BUILD}
echo ::set-output name=SEMVER_BUILD::${SEMVER_BUILD}

# if tag already has MAJOR.MINOR.PATCH add git log commit count to patch
if [[ "${#CURRENT_VERSION_ARRAY[@]}" == "4" ]]; then
echo "ADD PATCH TO BUILD VERSION"
export SEMVER_BUILD=$(( ${SEMVER_PATCH} + ${SEMVER_BUILD} ))
echo ::set-env name=SEMVER_BUILD::${SEMVER_BUILD}
echo ::set-output name=SEMVER_BUILD::${SEMVER_BUILD}
fi

echo "SEMVER_MAJOR:${SEMVER_MAJOR}"
Expand All @@ -39,13 +44,16 @@ fi

export SEMVER=${SEMVER_MAJOR}.${SEMVER_MINOR}.${SEMVER_BUILD}
echo ::set-env name=SEMVER::${SEMVER}
echo ::set-output name=SEMVER::${SEMVER}
echo "SEMVER:${SEMVER}"
if [[ ${SEMVER_MAJOR} == "" ]];then
echo PLEASE ADD TAG TO YOUR BRANCH
exit 1;
fi
export GITHUB_TAG=${SEMVER}
echo ::set-env name=GITHUB_TAG::${GITHUB_TAG}
echo ::set-output name=GITHUB_TAG::${GITHUB_TAG}
echo "GITHUB_TAG:${GITHUB_TAG}"
export GIT_RELEASE_NOTES="$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h - %s (%an)")"
echo ::set-env name=GIT_RELEASE_NOTES::${GIT_RELEASE_NOTES}
echo ::set-output name=GIT_RELEASE_NOTES::${GIT_RELEASE_NOTES}

0 comments on commit 6267cfd

Please sign in to comment.