#!/usr/bin/env bash set -euo pipefail # For the workshop, expect the password to match the username GIT_PASSWORD=${GIT_USER} # Consume parameters from Environment Variables if [[ -z "${BRANCH}" ]]; then REMOTE_BRANCH="origin/main" else REMOTE_BRANCH="origin/${BRANCH}" fi # Set global git parameters git config --global user.name "$GIT_USER" git config --global user.email "$GIT_EMAIL" git config --global init.defaultBranch 'main' cd /usr/local/bin/ignition/data/projects || exit if [ ! -d '.git' ]; then git init git remote add origin "https://$GIT_USER:$GIT_PASSWORD@$GIT_HOSTNAME:$GIT_PORT/$GIT_ORG/$GIT_REPO.git" git fetch #git reset origin/main # Required when the versioned files existed in path before "git init" of this repo. git checkout -t "${REMOTE_BRANCH}" fi