Skip to content

Commit 2153afc

Browse files
handle tagged releases and remove anchor example (#35)
* handle tagged releases and remove anchor example * handle tagged releases and remove anchor example
1 parent 3f77fae commit 2153afc

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

src/examples/references.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/scripts/clone_required_repos.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Function to log environment variables
44
LogEnvironmentVariables() {
55
echo "Logging Environment Variables:"
6+
echo "CIRCLE_BRANCH: $CIRCLE_BRANCH"
7+
echo "CIRCLE_TAG: $CIRCLE_TAG"
68
echo "CIRCLE_REPOSITORY_URL: $CIRCLE_REPOSITORY_URL"
79
echo "SOURCE_REPO_DIRECTORY: $SOURCE_REPO_DIRECTORY"
810
echo "TARGET_REPO: $TARGET_REPO"
@@ -28,8 +30,21 @@ AddGithubToKnownHosts() {
2830

2931
# Function to clone the source repository
3032
CloneSourceRepo() {
31-
echo "Cloning the $CIRCLE_BRANCH branch of source repository ($CIRCLE_REPOSITORY_URL) to $SOURCE_REPO_DIRECTORY" >&2
32-
git clone --branch "$CIRCLE_BRANCH" "$CIRCLE_REPOSITORY_URL" "$SOURCE_REPO_DIRECTORY" || { echo "Failed to clone source repository"; exit 1; }
33+
if [ -n "$CIRCLE_TAG" ]; then
34+
# For tag builds, checkout the commit instead of a branch
35+
echo "Cloning source repository ($CIRCLE_REPOSITORY_URL) for tag $CIRCLE_TAG to $SOURCE_REPO_DIRECTORY" >&2
36+
git clone "$CIRCLE_REPOSITORY_URL" "$SOURCE_REPO_DIRECTORY" || { echo "Failed to clone source repository"; exit 1; }
37+
cd "$SOURCE_REPO_DIRECTORY" || { echo "Failed to change directory to $SOURCE_REPO_DIRECTORY"; exit 1; }
38+
git checkout "$CIRCLE_TAG"
39+
elif [ -n "$CIRCLE_BRANCH" ]; then
40+
# For branch builds, checkout the specific branch
41+
echo "Cloning the $CIRCLE_BRANCH branch of source repository ($CIRCLE_REPOSITORY_URL) to $SOURCE_REPO_DIRECTORY" >&2
42+
git clone --branch "$CIRCLE_BRANCH" "$CIRCLE_REPOSITORY_URL" "$SOURCE_REPO_DIRECTORY" || { echo "Failed to clone source repository"; exit 1; }
43+
cd "$SOURCE_REPO_DIRECTORY" || { echo "Failed to change directory to $SOURCE_REPO_DIRECTORY"; exit 1; }
44+
else
45+
echo "Neither CIRCLE_BRANCH nor CIRCLE_TAG is set. Unable to determine which branch or tag to clone." >&2
46+
exit 1
47+
fi
3348
}
3449

3550
# Function to clone the target repository

0 commit comments

Comments
 (0)