latex-packages/.ci/setup_build_repo_branch.sh

20 lines
758 B
Bash
Raw Normal View History

2021-10-24 10:35:53 +02:00
# ! /bin/sh
2022-01-30 21:36:18 +01:00
set -e
2023-10-18 09:22:08 +02:00
2021-10-24 10:35:53 +02:00
cd build/LatexPackagesBuild
2023-10-18 09:22:08 +02:00
2023-10-18 10:26:11 +02:00
REMOTE_BRANCH=$(git branch -a | sed -n '/remotes\/origin\/.*-build/p' | sed 's/remotes\/origin\///g' | sed 's/-build//g' | sed 's/[[:space:]]//g' | sed -n "/^${REF_NAME}$/p")
2021-10-24 10:35:53 +02:00
echo ${REMOTE_BRANCH}
2023-10-18 09:22:08 +02:00
if [ "$REMOTE_BRANCH" = "" ]; then
2021-10-24 10:35:53 +02:00
echo "This is the first build on this branch, creating new branch in build repository to push to"
git checkout --orphan ${CI_COMMIT_REF_NAME}-build
ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' | xargs -r git rm --cached
ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' | xargs -r rm -rf
else
echo "Checking out remote branch from last build"
git checkout -b ${REMOTE_BRANCH}-build origin/${REMOTE_BRANCH}-build
fi
cd ../..