From 4ff37085e4ac6cb8750843c3d2d5a2325eccf206 Mon Sep 17 00:00:00 2001
From: TIm Kluge <timklge@gmail.com>
Date: Thu, 16 Apr 2020 14:57:29 +0200
Subject: [PATCH] Adds Gitlab CI

---
 .gitlab-ci.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 README.md      |  5 +++++
 2 files changed, 52 insertions(+)
 create mode 100644 .gitlab-ci.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..8ad7206
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,47 @@
+image: aergus/latex
+
+variables:
+  FILENAME: main
+  FILEDIR: .
+  DIFFCMD: bash git-latexdiff --exclude-textcmd="section,subsection,author" -b --main $FILENAME.tex --latexmk
+
+stages:
+  - build
+  - diff
+
+build:
+  stage: build
+  tags:
+    - dockered
+  artifacts:
+    paths:
+      - $FILEDIR/paper.pdf
+      - $FILEDIR/build_paper.log
+  script:
+    - cd "$FILEDIR"
+    - latexmk -pdf "$FILENAME.tex" 2>&1 | tee build_paper.log
+    - bash -c 'mv $FILENAME.pdf paper.pdf; true'
+# - 'grep -v "LaTeX Warning: There were undefined references." build_paper.log'
+
+# diff is not working most of the time
+# diff:
+#   stage: diff
+#   tags:
+#     - dockered
+#   artifacts:
+#     paths:
+#       - $FILEDIR/difftag_paper.pdf
+#       - $FILEDIR/difftag_paper.log
+#       - $FILEDIR/diffcommit_paper.pdf
+#   script:
+#     - cd "$FILEDIR"
+#     - LAST_TAG=$(git describe --abbrev=0 --tags HEAD~1)
+#     - wget https://gitlab.com/git-latexdiff/git-latexdiff/raw/ef53cddc761ce2d278ba5016d17828cf63e30af5/git-latexdiff
+#     - if [ "$LAST_TAG" ] ; then
+#     -   $DIFFCMD -o "difftag_paper.pdf" "$LAST_TAG" 2>&1 | tee difftag_paper.log
+#     - fi
+#     - if [ "$CI_BEFORE_SHA" ] ; then
+#     -   $DIFFCMD -o "diffcommit_paper.pdf" "$CI_BEFORE_SHA"
+#     - fi
+#   allow_failure: true
+
diff --git a/README.md b/README.md
index d02bf94..6b1e379 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,8 @@
+[![pipeline status](/../badges/master/pipeline.svg)](/../pipelines)
+
+* [Latest PDF online](/../-/jobs/artifacts/master/file/paper.pdf?job=build)
+    * [Build Log](/../-/jobs/artifacts/master/file/build_paper.log?job=build)
+
 # Deep modeling for self-reproducing robots
 > This is a paper about how to use deep modeling to describe a self-reproducing robots control system
 
-- 
GitLab