Newer
Older
# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/plain-html
# always test the preprocessor with unit tests
test-preprocessor:
stage: testing
allow_failure: false
image:
name: alpine:latest
script:
- apk add --no-cache --upgrade bash
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
# run shell script with testss
- $RESEARCH_ROOT/bin/test_preprocessor.sh
artifacts:
paths:
- testing/test_preprocessor/*.log
only:
refs:
- branches
- merge_requests
changes:
- .gitlab-ci.yml
- bin
- testing
test-extract-title:
stage: testing
allow_failure: false
image:
name: alpine:latest
script:
- apk add --no-cache --upgrade bash
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
# run shell script with tests
- $RESEARCH_ROOT/bin/test_extract_title.sh
artifacts:
paths:
- testing/test_extract_title/*.log
only:
refs:
- branches
- merge_requests
changes:
- .gitlab-ci.yml
- bin
- testing
# always test the pandoc integration and pandoc build with unit tests
pandoc-test:
stage: testing
allow_failure: false
image:
name: alpine:latest
script:
- apk add --no-cache --upgrade bash
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
# run shell script with testss
- $RESEARCH_ROOT/bin/test_pandoc.sh
artifacts:
paths:
- testing/test_pandoc/*.log
# test that markdown is translated correctly
test-create-html:
stage: testing
allow_failure: false
image:
name: eltenedor/ubuntu-pandoc:latest
script:
- mkdir -p log
- rm -rf log/test_create_html.log
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
- $RESEARCH_ROOT/bin/test_create_html.sh
artifacts:
paths:
- log/create_html.log
only:
refs:
- branches
- merge_requests
changes:
- .gitlab-ci.yml
- bin
- testing
# test that html is included correctly
test-replace_marker:
stage: testing
allow_failure: false
image:
name: eltenedor/ubuntu-pandoc:latest
script:
- mkdir -p log
- rm -rf log/test_replace_marker.log
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
- $RESEARCH_ROOT/bin/test_replace_marker.sh
artifacts:
paths:
- log/test_replace_marker.log
only:
refs:
- branches
- merge_requests
changes:
- .gitlab-ci.yml
- bin
- testing
# test building standalone static webpage
test-build-standalone:
stage: testing
allow_failure: false
image:
name: eltenedor/ubuntu-pandoc:latest
script:
- mkdir -p log
- rm -rf log/test_build_standalone.log
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
- $RESEARCH_ROOT/bin/test_build_standalone.sh
artifacts:
paths:
- log/build_standalone.log
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
only:
refs:
- branches
- merge_requests
changes:
- .gitlab-ci.yml
- bin
- testing
# build standalone static webpage
build-standalone-static:
stage: build
allow_failure: false
image:
name: eltenedor/ubuntu-pandoc:latest
script:
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
# build static webpage
- $RESEARCH_ROOT/bin/build_standalone.sh
artifacts:
paths:
- public
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH
# build standalone static webpage
build-static:
stage: build
allow_failure: false
image:
name: eltenedor/ubuntu-pandoc:latest
script:
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
# build static webpage
- $RESEARCH_ROOT/bin/build_static.sh
artifacts:
paths:
- static
rules:
- if: $CI_MERGE_REQUEST_ID
# build tuhh-snippets
build-tuhh:
stage: build
allow_failure: false
image:
name: eltenedor/ubuntu-pandoc:latest
script:
- RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
artifacts:
paths:
- build-tuhh
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH
# deploy static webpage on issue-branch to web-server hosted asteroids
deploy-on-asteroid:
stage: review
image:
name: alpine:latest
before_script:
## install dependencies
#- apk update && apk add openssh-client bash
## see https://docs.gitlab.com/ee/ci/ssh_keys/ for comments
#- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' #this command is for debian based systems
- apk update && apk add openssh-client bash #this command is for alpine
- eval $(ssh-agent -s)
- echo "$ASTEROID_SSH_KEY" | tr -d '\r' | ssh-add -
# See https://stackoverflow.com/a/57332478 about known hosts
- mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
- echo "$ASTEROID_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 700 ~/.ssh
script:
- mkdir .public-asteroid
- cp -r public/*.html .public-asteroid
- cp -r img .public-asteroid
- cp -r css .public-asteroid
- mv .public-asteroid public-asteroid
# deploy webpage on asteroid
#- ssh $ASTEROID_USER@$ASTEROID_HOST "rm -rf $ASTEROID_DEPLOY/$CI_COMMIT_REF_NAME"
- ssh $ASTEROID_USER@$ASTEROID_HOST "mkdir -p $ASTEROID_DEPLOY/$CI_COMMIT_REF_NAME"
- scp -v -r public-asteroid "$ASTEROID_USER@$ASTEROID_HOST:$ASTEROID_DEPLOY/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHORT_SHA"
artifacts:
paths:
- public-asteroid
rules:
- if: $CI_PROJECT_URL != 'https://collaborating.tuhh.de/cfg0846/research-topics-mat-tuhh'
when: never
- when: always
# deploy static webpage on dev-branch to tuhh
deploy-on-tuhh:
stage: deploy
image:
name: alpine:latest
before_script:
## install dependencies
- apk update && apk add openssh-client bash
- eval $(ssh-agent -s)
- echo "$REVIEW_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
- echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/known_hosts
- echo "Deploying on www3-dev.tuhh.de"
# deploy webpage on tuhh
#- rsync -v -r -a --delete -e "ssh" build-tuhh/* $TUHH_USER@$TUHH_HOST:$TUHH_DEPLOY/tes
- ssh -v -p "${REVIEW_SSH_PORT}" "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}" "mkdir -p /usr/local/apache2/htdocs/~dev
- scp -v -P "${REVIEW_SSH_PORT}" -r build-tuhh/* "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}":"/usr/local/apache2/htdocs/~dev
artifacts:
paths:
- if: $CI_PROJECT_URL != 'https://collaborating.tuhh.de/cfg0846/research-topics-mat-tuhh'
when: never
- if: $CI_COMMIT_BRANCH != 'dev'
when: always
# deploy static webpage to web-server via GitLab pages
- echo "Running GitLab Pages"
deploy_review:
stage: deploy
script:
- echo "Deploy a review app on an asteroid"
name: asteroid/$CI_COMMIT_REF_NAME
url: https://review.fabian-gabel.de/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHORT_SHA
# on_stop: stop_review_app
# auto_stop_in: 1 week
rules:
- if: $CI_PROJECT_URL != 'https://collaborating.tuhh.de/cfg0846/research-topics-mat-tuhh'
when: never
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH == 'dev'
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
review_tuhh:
stage: review
image:
name: alpine:latest
before_script:
- apk update && apk add openssh-client bash
- eval $(ssh-agent -s)
- echo "$REVIEW_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
- echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/known_hosts
script:
- mkdir .public-review
- cp -r public/*.html .public-review
- cp -r img .public-review
- cp -r css .public-review
- mv .public-review public-review
- ssh -v -p "${REVIEW_SSH_PORT}" "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}" "mkdir -p /usr/local/apache2/htdocs/~${CI_COMMIT_REF_NAME}/$CI_COMMIT_SHORT_SHA"
- scp -v -P "${REVIEW_SSH_PORT}" -r public-review/* "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}":"/usr/local/apache2/htdocs/~${CI_COMMIT_REF_NAME}/$CI_COMMIT_SHORT_SHA"
environment:
name: tuhh/$CI_COMMIT_REF_NAME
url: https://${REVIEW_PROXY_HOST_NAME}${REVIEW_BASE_DIR}~${CI_COMMIT_REF_NAME}/$CI_COMMIT_SHORT_SHA/
on_stop: review_tuhh:stop
rules:
- if: $CI_PROJECT_URL != 'https://collaborating.tuhh.de/cfg0846/research-topics-mat-tuhh'
when: never
- if: '$CI_COMMIT_REF_NAME != "master"'
review_tuhh:stop:
stage: review
image:
name: alpine:latest
before_script:
- apk update && apk add openssh-client bash
- eval $(ssh-agent -s)
- echo "$REVIEW_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
- echo "$REVIEW_SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/known_hosts
script:
- ssh -p "${REVIEW_SSH_PORT}" "${REVIEW_SSH_USER}"@"${REVIEW_HOST_NAME}" "rm -rf /usr/local/apache2/htdocs/~${CI_COMMIT_REF_NAME}"
rules:
- if: '$CI_COMMIT_REF_NAME != "master"'
when: manual
allow_failure: true
environment:
name: tuhh/$CI_COMMIT_REF_NAME
action: stop
master-deploy:
stage: deploy
image:
name: alpine:latest
before_script:
- apk update && apk add openssh-client bash
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 700 ~/.ssh/known_hosts
script:
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- ssh -p "${SSH_PORT}" "${SSH_USER}"@"${HOST_NAME}" "mkdir -p /usr/local/apache2/htdocs"
- scp -P "${SSH_PORT}" -r public/* "${SSH_USER}"@"${HOST_NAME}":"/usr/local/apache2/htdocs"
cache:
key: "$CI_COMMIT_REF_SLUG"
environment:
name: $CI_COMMIT_REF_NAME
url: https://$PROXY_HOST_NAME$BASE_DIR
rules:
- if: $CI_PROJECT_URL != 'https://collaborating.tuhh.de/cfg0846/research-topics-mat-tuhh'
when: never
- if: '$CI_COMMIT_REF_NAME == "master"'
rsync-tuhh-deploy:
stage: deploy
image:
name: alpine:latest
before_script:
## install dependencies
- apk update && apk add openssh-client bash rsync
## see https://docs.gitlab.com/ee/ci/ssh_keys/ for comments
#- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$TUHH_SSH_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && touch ~/.ssh/known_hosts
- echo "$TUHH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 700 ~/.ssh
script:
- mkdir -p .public-tuhh
- cp -r build-tuhh/*.html .public-tuhh
- cp -r build-tuhh/img .public-tuhh
- mv .public-tuhh public-tuhh
# deploy webpage on tuhh
#- echo 'scp -v public-tuhh' "$TUHH_USER@$TUHH_HOST:$TUHH_DEPLOY"
#- scp -v -r public-tuhh "$TUHH_USER@$TUHH_HOST:$TUHH_DEPLOY"
- rsync -v -r -a --delete -e "ssh" public-tuhh/ $TUHH_USER@$TUHH_HOST:$TUHH_DEPLOY/test
artifacts:
paths:
- public-tuhh
rules:
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_BRANCH
# uncomment for manual stopping
#stop_review_app:
# stage: deploy
# script: stop-review-app
# environment:
# name: review/$CI_COMMIT_REF_NAME
# action: stop
# rules:
# - if: $CI_MERGE_REQUEST_ID