Skip to content

Instantly share code, notes, and snippets.

@rafaellehmkuhl
Last active August 27, 2021 16:26
Show Gist options
  • Save rafaellehmkuhl/5fc9e5add2374d7796d8808b2e90311d to your computer and use it in GitHub Desktop.
Save rafaellehmkuhl/5fc9e5add2374d7796d8808b2e90311d to your computer and use it in GitHub Desktop.
PBaP - Push branch updates, Build them on rasp and Push them to register on just one command
BRANCH_NAME=$1
IMAGE_NAME=$1
cd /home/pi/companion-docker/core
echo "Checking out to branch ${BRANCH_NAME}."
git checkout $BRANCH_NAME || git checkout -b $BRANCH_NAME
echo "Fetching updates from remotes."
git fetch --all
echo "Reseting to master."
git reset --hard master
echo "Pulling changes from remote."
git pull origin $BRANCH_NAME
echo "Building image ${IMAGE_NAME}"
docker build . -t rafaellehmkuhl/companion-core:$IMAGE_NAME
echo "Logging into Dockerhub."
docker login
echo "Pushing image."
docker push rafaellehmkuhl/companion-core:$IMAGE_NAME
BRANCH_NAME=$(git branch --show-current)
git push origin $BRANCH_NAME --force-with-lease
ssh [email protected] 'bash -s' < auto_build.sh $BRANCH_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment