}
function isCI {
- [[ "${CI-false}" = "true" ]] || isAzurePipelines || isGitHubActions
-}
-
-function isAzurePipelines {
- [[ "${TF_BUILD-False}" = "True" ]]
+ [[ "${CI-false}" = "true" ]] || isGitHubActions
}
function isGitHubActions {
fi
name="$1"
- if isAzurePipelines; then
- [[ "${BUILD_SOURCEBRANCHNAME}" = "${name}" ]]
- elif isGitHubActions; then
+ if isGitHubActions; then
[[ "${GITHUB_REF}" = "refs/heads/${name}" ]]
else
echo "isCiBranch only works inside CI!"
}
function ciBaseBranch {
- if isAzurePipelines; then
- echo "unsupported on Azure Pipelines"
- exit 1
- elif isGitHubActions; then
+ if isGitHubActions; then
echo "${GITHUB_BASE_REF#refs/heads/}"
else
echo "ciBaseBranch only works inside CI!"
}
function ciCommit {
- if isAzurePipelines; then
- echo "${BUILD_SOURCEVERSION}"
- elif isGitHubActions; then
+ if isGitHubActions; then
echo "${GITHUB_SHA}"
else
echo "ciCommit only works inside CI!"
}
function ciCheckoutPath {
- if isAzurePipelines; then
- echo "${BUILD_SOURCESDIRECTORY}"
- elif isGitHubActions; then
+ if isGitHubActions; then
echo "${GITHUB_WORKSPACE}"
else
echo "ciCheckoutPath only works inside CI!"
fi
path="$1"
- if isAzurePipelines; then
- echo "##vso[task.prependpath]${path}"
- elif isGitHubActions; then
+ if isGitHubActions; then
echo "${path}" >> "${GITHUB_PATH}"
else
echo "ciCommandAddPath only works inside CI!"
name="$1"
value="$2"
- if isAzurePipelines; then
- echo "##vso[task.setvariable variable=${name}]${value}"
- elif isGitHubActions; then
+ if isGitHubActions; then
echo "${name}=${value}" >> "${GITHUB_ENV}"
else
echo "ciCommandSetEnv only works inside CI!"