Skip to content

Commit

Permalink
Try to use a matching branch from core
Browse files Browse the repository at this point in the history
  • Loading branch information
jagthedrummer committed Aug 7, 2023
1 parent ff210c6 commit 656f374
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
- restore_cache: *restore_bundler_cache
- restore_cache: *restore_yarn_cache

- run: ../../bin/checkout-and-link-starter-repo

# Install dependencies
- ruby/bundle-install
- run: bin/link
Expand Down Expand Up @@ -144,6 +146,8 @@ jobs:
- restore_cache: *restore_bundler_cache
- restore_cache: *restore_yarn_cache

- run: ../../bin/checkout-and-link-starter-repo

# Install dependencies
- ruby/bundle-install
- run: bundle clean --force
Expand Down Expand Up @@ -195,6 +199,8 @@ jobs:
- restore_cache: *restore_bundler_cache
- restore_cache: *restore_yarn_cache

- run: ../../bin/checkout-and-link-starter-repo

# Install dependencies
- ruby/bundle-install
- run: bin/link
Expand Down
71 changes: 71 additions & 0 deletions bin/checkout-and-link-core-repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

# Default to the main branch if we don't find a matching branch on the starter repository.
CORE_REPO_BRANCH="main"

# Look for a matching branch on the starter repository when running tests on CircleCI.
CI_BRANCH=$CIRCLE_BRANCH
if [[ -v CI_BRANCH ]]
then
# Default to the main branch if we don't find a matching branch on the starter repository.
BRANCH_NAMES_JSON=$(curl -H "Accept: application.vnd.github+json" "https://api.github.com/repos/bullet-train-co/bullet_train-core/branches?per_page=100")
#echo "This is what we're getting from the GitHub API:"
#echo "${BRANCH_NAMES_JSON}"
BRANCH_NAMES=$(echo $BRANCH_NAMES_JSON | jq -r '.[].name')
echo "These are the branches on the core repo:"
echo "${BRANCH_NAMES}"

for BRANCH in $BRANCH_NAMES; do
if [ ${BRANCH} == $CIRCLE_BRANCH ]
then
CORE_REPO_BRANCH=$BRANCH
break
fi
done
fi


if [ $CORE_REPO_BRANCH == "main" ]
then
# Do nothing and use the published version of the gems?
else

echo "Cloning from ${CORE_REPO_BRANCH}..."
git clone -b $CORE_REPO_BRANCH --depth 1 https://github.com/bullet-train-co/bullet_train.git .

# TODO: Maybe generate this list automatically based on the subdirectories in core that contain a .gemspec?
packages=(
"bullet_train"
"bullet_train-api"
"bullet_train-fields"
"bullet_train-has_uuid"
"bullet_train-incoming_webhooks"
"bullet_train-integrations"
"bullet_train-integrations-stripe"
"bullet_train-obfuscates_id"
"bullet_train-outgoing_webhooks"
"bullet_train-roles"
"bullet_train-scope_questions"
"bullet_train-scope_validator"
"bullet_train-sortable"
"bullet_train-super_load_and_authorize_resource"
"bullet_train-super_scaffolding"
"bullet_train-themes"
"bullet_train-themes-light"
"bullet_train-themes-tailwind_css"
)

for package in "${packages[@]}"
do
:
grep -v "gem \"$package\"" Gemfile > Gemfile.tmp
mv Gemfile.tmp Gemfile
echo "gem \"$package\", path: \"../../$package\"" >> Gemfile
done

updates="${packages[@]}"
bundle lock --update $updates

fi


0 comments on commit 656f374

Please sign in to comment.