.gitlab-ci.yml 3.31 KB
Newer Older
mrodzis's avatar
mrodzis committed
1
2
3
4
5
6
# this file defines the CI/CD stages for Ahiqar's front end.
#
# this config uses custom Docker images to keep the pipelines fast.
# see https://gitlab.gwdg.de/mrodzis/docker-images/ for more 
# info about them.

Mathias Goebel's avatar
Mathias Goebel committed
7
8
9
10
11
12
13
.ssh-config: &ssh
- which ssh-agent
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh

Mathias Goebel's avatar
Mathias Goebel committed
14
15
16
17
18
19
20
21
22
23
.deloyment: &deploy
# set entry point for develop
- sed -i "s ahikar.*\.sub $SERVER.sub g" tido/dist/index.html
# arabic-karshuni
## remove old version
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/$TARGET/frontend/arabic-karshuni/*"
## upload new version
- scp -o 'StrictHostKeyChecking no' -r tido/dist/* $SSH_USER@$SSH_IP:~/$TARGET/frontend/arabic-karshuni/
# syriac
## remove old version
24
- sed -i 's textapi/ahikar/arabic-karshuni textapi/ahikar/syriac/ g' tido/dist/index.html
Mathias Goebel's avatar
Mathias Goebel committed
25
26
27
28
29
30
31
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/$TARGET/frontend/syriac/*"
## upload new version
- scp -o 'StrictHostKeyChecking no' -r tido/dist/* $SSH_USER@$SSH_IP:~/$TARGET/frontend/syriac/
# upload css
- scp -o 'StrictHostKeyChecking no' ahikar.css $SSH_USER@$SSH_IP:~/$TARGET/frontend/


Mathias Goebel's avatar
Mathias Goebel committed
32
33
34
35
36
37
38
## GLOBAL VARIABLES
variables:
  # ↓ needed to handle concurrency
  # ↓ see https://docs.gitlab.com/ee/ci/runners/configure_runners.html#handling-concurrency
  GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_PATH/$CI_JOB_NAME
  # ↓ reduces the amount of data transfered to the runner (shallow clone)
  GIT_DEPTH: 2
Mathias Goebel's avatar
Mathias Goebel committed
39

40
stages:
41
  - update-projects
Mathias Goebel's avatar
Mathias Goebel committed
42
43
  - build
  - deploy
44
  - update-backend
Mathias Goebel's avatar
Mathias Goebel committed
45

mrodzis's avatar
mrodzis committed
46
47
48
49
# automatically updates the project specific viewer on changes of the
# generic TIDO viewer. when a change is detected, the QViewer submodule
# is updated.

Mathias Goebel's avatar
Mathias Goebel committed
50
# this stage is triggered by the pipelines of https://gitlab.gwdg.de/subugoe/emo/tido.
51
update-viewer:
Michelle Weidling's avatar
Michelle Weidling committed
52
  image: curlimages/curl:7.73.0
53
54
55
56
57
  stage: update-projects
  rules:
    - if: '$UPDATE == "true"'
    - if: '$UPSTREAM_COMMIT_SHA'
  script:
Nils Windisch's avatar
Nils Windisch committed
58
    - 'curl --request PUT --header "PRIVATE-TOKEN: $PROJECT_ACCESS_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/submodules/tido" --data "branch=develop&commit_sha=$UPSTREAM_COMMIT_SHA&commit_message=update: TIDO"' 
59

mrodzis's avatar
mrodzis committed
60
61
# build the front end viewer with a custom index.html. for this the custom index.template.html
# provided in this repo is copied to the correct place in TIDO before the build.
Mathias Goebel's avatar
Mathias Goebel committed
62
build:
Nils Windisch's avatar
Nils Windisch committed
63
  image: docker.gitlab.gwdg.de/subugoe/emo/tido/node:latest
Mathias Goebel's avatar
Mathias Goebel committed
64
65
  stage: build
  variables:
mrodzis's avatar
mrodzis committed
66
    # when we want to include the front end templating, we have to use recursive
Mathias Goebel's avatar
Mathias Goebel committed
67
    GIT_SUBMODULE_STRATEGY: normal
Mathias Goebel's avatar
Mathias Goebel committed
68
  script:
69
   - ./set-entrypoint.sh
Nils Windisch's avatar
Nils Windisch committed
70
71
   - cp --force index.html tido/src/index.template.html
   - cd tido
Mathias Goebel's avatar
Mathias Goebel committed
72
   - npm install
mrodzis's avatar
mrodzis committed
73
74
   - npm run build
   - npm run tweak:build
Mathias Goebel's avatar
Mathias Goebel committed
75
  artifacts:
Mathias Goebel's avatar
Mathias Goebel committed
76
    expire_in: 3 mos
Mathias Goebel's avatar
Mathias Goebel committed
77
    paths:
Nils Windisch's avatar
Nils Windisch committed
78
     - tido/dist/
mrodzis's avatar
mrodzis committed
79
     - ahikar.css
Mathias Goebel's avatar
Mathias Goebel committed
80

81

Mathias Goebel's avatar
Mathias Goebel committed
82
83
84
85
update_backend-test:
  stage: update-backend
  image: rsamban/scp-resource:latest
  variables:
Mathias Goebel's avatar
Mathias Goebel committed
86
87
    TARGET: "test"
    SERVER: "ahikar-test"
Mathias Goebel's avatar
Mathias Goebel committed
88
89
90
91
  script:
    - *ssh
    - *deploy

Mathias Goebel's avatar
Mathias Goebel committed
92
update_backend-develop:
93
  stage: update-backend
Mathias Goebel's avatar
Mathias Goebel committed
94
95
96
  image: rsamban/scp-resource:latest
  only:
    - develop
Mathias Goebel's avatar
Mathias Goebel committed
97
  variables:
Mathias Goebel's avatar
Mathias Goebel committed
98
99
    TARGET: "develop"
    SERVER: "ahikar-dev"
Mathias Goebel's avatar
Mathias Goebel committed
100
  script:
Mathias Goebel's avatar
Mathias Goebel committed
101
    - *ssh
Mathias Goebel's avatar
Mathias Goebel committed
102
    - *deploy
Mathias Goebel's avatar
Mathias Goebel committed
103

Mathias Goebel's avatar
Mathias Goebel committed
104
update_backend-main:
105
  stage: update-backend
Mathias Goebel's avatar
Mathias Goebel committed
106
107
108
  image: rsamban/scp-resource:latest
  only:
    - main
Mathias Goebel's avatar
Mathias Goebel committed
109
  variables:
Mathias Goebel's avatar
Mathias Goebel committed
110
111
    TARGET: "main"
    SERVER: "ahikar"
Mathias Goebel's avatar
Mathias Goebel committed
112
  script:
Mathias Goebel's avatar
Mathias Goebel committed
113
    - *ssh
Mathias Goebel's avatar
Mathias Goebel committed
114
    - *deploy