set up gitlab ci. first try

This commit is contained in:
Maximilian Keßler 2021-10-24 00:44:49 +02:00
parent 2b38738aa8
commit b8678b1f6c
7 changed files with 89 additions and 6 deletions

View file

@ -1,7 +1,7 @@
cd .travis cd .ci
export COMMIT_MSG=$(python3 print_deploy_message.py) export COMMIT_MSG=$(python3 print_deploy_message.py)
cd .. cd ..
make travis make ci-build
cd build cd build
zip -r LatexPackages.zip LatexPackagesBuild zip -r LatexPackages.zip LatexPackagesBuild
tree -H '.' -I "index.html" -D --charset utf-8 -T "LatexPackages" > index.html tree -H '.' -I "index.html" -D --charset utf-8 -T "LatexPackages" > index.html

View file

@ -1,13 +1,14 @@
# ! /bin/sh # ! /bin/sh
git clone https://github.com/kesslermaximilian/LatexPackagesBuild.git build/LatexPackagesBuild ssh git@gitlab.com
git clone git@gitlab.com:latexci/packages/LatexPackagesBuild.git build/LatexPackagesBuild
cd build/LatexPackagesBuild cd build/LatexPackagesBuild
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 "/^${TRAVIS_BRANCH}$/p") 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 "/^${CI_COMMIT_REF_NAME}$/p")
echo ${REMOTE_BRANCH} echo ${REMOTE_BRANCH}
if [ "$REMOTE_BRANCH" = "" ];then if [ "$REMOTE_BRANCH" = "" ];then
echo "This is the first build on this branch, creating new branch in build repository to push to" echo "This is the first build on this branch, creating new branch in build repository to push to"
git checkout --orphan ${TRAVIS_BRANCH}-build 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 git rm --cached
ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' | xargs -r rm -rf ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' | xargs -r rm -rf
else else

82
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,82 @@
stages: # List of stages for jobs, and their order of execution
- get
- build
- deploy
get-build-repo: # This job runs in the build stage, which runs first.
stage: get
before_script:
- apt-get update -y && apt-get install -yqqf openssh-client git unzip sshpass rsync --fix-missing
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
- eval $(ssh-agent -s)
- echo "$GITLAB_DEPLOY_KEY" | base64 -d | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.email "git@maximilian-kessler.de"
- git config --global user.name "Maximilian Keßler (via gitlab runner)"
script:
- "Getting old Build repo..."
- .ci/get_build_repo_from_origin.sh
tags:
- latex
artifacts:
paths:
- build/
build-packages: # This job runs in the deploy stage.
stage: build # It only runs when *both* jobs in the test stage complete successfully.
before_script:
- apt-get update -y && apt-get install -yqqf openssh-client git unzip sshpass rsync --fix-missing
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
- eval $(ssh-agent -s)
- echo "$GITLAB_DEPLOY_KEY" | base64 -d | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.email "git@maximilian-kessler.de"
- git config --global user.name "Maximilian Keßler (via gitlab runner)"
script:
- echo "Building packages incrementally..."
- .ci/ci_build.sh
- cd build/LatexPackagesBuild
- git add .
- git commit -m "${COMMIT_MESSAGE}"
artifacts:
paths:
- build/
tags:
- latex
pages:
stage: deploy
artifacts:
paths:
- public
before_script:
- apt-get update -y && apt-get install -yqqf openssh-client git unzip sshpass rsync --fix-missing
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
- eval $(ssh-agent -s)
- echo "$GITLAB_DEPLOY_KEY" | base64 -d | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.email "git@maximilian-kessler.de"
- git config --global user.name "Maximilian Keßler (via gitlab runner)"
script:
- cd build/LatexPackagesBuild
- git push origin
tags:
- latex

View file

@ -28,5 +28,5 @@ config: .gitconfiglock
clean: clean:
@-rm -r build/ @-rm -r build/
travis: ci-build:
@python3 build.py --source-dir src --build-dir build/LatexPackagesBuild ${BUILD_FLAGS} @python3 build.py --source-dir src --build-dir build/LatexPackagesBuild ${BUILD_FLAGS}