Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get-template-library: add support for GitHub Actions #364

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/scripts/get-template-library
Original file line number Diff line number Diff line change
Expand Up @@ -235,30 +235,37 @@ fi


# --continuous-integration: check environment
# NOTE: currently only Travis is supported
# NOTE: currently only GitHub Actions or Travis are supported
if [ ${use_ci_work_dir} -eq 1 ]
then
[ ${verbose} -eq 1 ] && echo "Configuring continuous integration mode..."
if [ -n "${TRAVIS_BUILD_DIR}" ]
if [ -n "${GITHUB_WORKSPACE}" ]
then
ci_work_dir=${GITHUB_WORKSPACE}
elif [ -n "${TRAVIS_BUILD_DIR}" ]
then
ci_work_dir=${TRAVIS_BUILD_DIR}
else
echo "Not in a Travis build environment: --continuous-integration invalid"
echo "Not in a GitHub Actions or Travis build environment: --continuous-integration invalid"
usage
fi
# $TRAVIS_REPO_SLUG contains the GitHub user/repo (e.g. quattor/template-library-core)
pr_repo=$(echo $TRAVIS_REPO_SLUG | sed -e 's%^quattor/%%')
# TRAVIS_REPO_SLUG contains the GitHub user/repo (e.g. quattor/template-library-core)
pr_repo="${GITHUB_REPOSITORY/#quattor\//}"
[[ -z "${pr_repo}" ]] && pr_repo="${TRAVIS_REPO_SLUG/#quattor\//}"
if [ -z "${pr_repo}" ]
then
echo "Current PR repository could not be retrieved from TRAVIS_REPO_SLUG env var"
echo "Current PR repository could not be retrieved from either GITHUB_REPOSITORY or TRAVIS_REPO_SLUG"
exit 2
fi
# TRAVIS_BRANCH contains the PR branch target
if [ -n "${TRAVIS_BRANCH}" ]
# GITHUB_BASE_REF or TRAVIS_BRANCH contains the PR branch target
if [ -n "${GITHUB_BASE_REF}" ]
then
pr_target=${GITHUB_BASE_REF}
elif [ -n "${TRAVIS_BRANCH}" ]
then
pr_target=${TRAVIS_BRANCH}
else
echo "TRAVIS_BRANCH not defined: not a Travis build environment, --continuous-integration invalid"
echo "Neither GITHUB_BASE_REF nor TRAVIS_BRANCH defined: not a GitHub Actions or Travis build environment, --continuous-integration invalid"
exit 2
fi
[ ${verbose} -eq 1 ] && echo "CI mode: ci_work_dir=${ci_work_dir}, pr_repo=${pr_repo}, pr_target=${pr_target}"
Expand Down