Commit 82c72db2 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

ci: move deployment strategy

parent 0b411fc4
......@@ -14,7 +14,7 @@ stages:
# generic TIDO viewer. when a change is detected, the QViewer submodule
# is updated.
# this stage is triggered by the pipelines of https://gitlab.gwdg.de/subugoe/emo/QViewer.
# this stage is triggered by the pipelines of https://gitlab.gwdg.de/subugoe/emo/tido.
update-viewer:
image: curlimages/curl:7.73.0
stage: update-projects
......@@ -45,61 +45,47 @@ build:
- tido/dist/
- ahikar.css
# when a git flow release is made, a tag will be pushed starting this job. it
# will keep the resulting artifact from the job declared in `JOB_NUMBER_TO_PRESERVE`
# and it will set up a Gitlab release at the repo. therefore the merge message starting
# at the release branch should be written in markdown, using a backslash as escape character
# `\` before `#`.
release:
image: docker.gitlab.gwdg.de/fontane-notizbuecher/build:latest
stage: deploy
only:
- tags
variables:
JOB_NUMBER_TO_PRESERVE: 1
script:
# it is also possible to query for a job name by altering the jq filter
- 'curl --output jobs.json --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs"'
- CI_JOB_TARGET=$(jq ".[$((JOB_NUMBER_TO_PRESERVE - 1))].id" < jobs.json)
- echo $CI_JOB_TARGET
# keep artifact (release will link there)
- 'curl --request POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$CI_JOB_TARGET/artifacts/keep"'
# create release data
# parse commit message (markdown, lines starting with “\”)
- MARKDOWN=$(echo "$CI_COMMIT_MESSAGE" | sed 's=^\\==g')
# prepare the json file
- 'jq
".name = \"$CI_PROJECT_PATH $CI_COMMIT_TAG\" |
.tag_name = \"$CI_COMMIT_TAG\" |
.description = \"$MARKDOWN\" |
.assets.links[0].name = \"package\" |
.assets.links[0].url = \"https://gitlab.gwdg.de/$CI_PROJECT_PATH/-/jobs/$CI_JOB_TARGET/artifacts/download\"
" < .gitlab/gitlab-release.json.tmpl > gitlab-release.json'
- 'curl --header "Content-Type: application/json" --header "PRIVATE-TOKEN: $GITLAB_TOKEN" --data @gitlab-release.json --request POST $CI_API_V4_URL/projects/$CI_PROJECT_ID/releases'
artifacts:
paths:
- gitlab-release.json
# triggers an update of the back end's develop branch when this repo's develop branch
# has new changes.
update-backend_develop:
update_backend-develop:
stage: update-backend
rules:
- if: '$CI_COMMIT_BRANCH == "develop"'
- if: '$UPDATE == "true"'
- if: '$UPSTREAM_COMMIT_SHA'
trigger:
project: subugoe/ahiqar/backend
branch: develop
image: rsamban/scp-resource:latest
only:
- develop
script:
- sed -i "s ahikar.*\.sub ahikar-dev.sub g" tido/dist/index.html
# arabic-karshuni
## remove old version
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/$CI_COMMIT_REF_NAME/frontend/arabic-karshuni/*"
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/test/frontend/arabic-karshuni/*"
## upload new version
- scp -o 'StrictHostKeyChecking no' -r tido/dist/* $SSH_USER@$SSH_IP:~/$CI_COMMIT_REF_NAME/frontend/arabic-karshuni/
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "cp -r ~/$CI_COMMIT_REF_NAME/frontend/arabic-karshuni/* ~/test/frontend/arabic-karshuni/
# syriac
## remove old version
- sed -i 's/textapi\/ahikar\/arabic-karshuni/textapi\/ahikar\/syriac/' tido/dist/index.html
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/$CI_COMMIT_REF_NAME/frontend/syriac/*"
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/test/frontend/syriac/*"
# upload css
- scp -o 'StrictHostKeyChecking no' ahikar.css $SSH_USER@$SSH_IP:~/$CI_COMMIT_REF_NAME/frontend/
- scp -o 'StrictHostKeyChecking no' ahikar.css $SSH_USER@$SSH_IP:~/test/frontend/
# triggers an update of the back end's main branch when this repo's main branch
# has new changes.
update-backend_main:
update_backend-main:
stage: update-backend
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$UPDATE == "true"'
- if: '$UPSTREAM_COMMIT_SHA'
trigger:
project: subugoe/ahiqar/backend
branch: main
image: rsamban/scp-resource:latest
only:
- main
script:
- sed -i "s ahikar.*\.sub ahikar-dev.sub g" tido/dist/index.html
# arabic-karshuni
## remove old version
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/$CI_COMMIT_REF_NAME/frontend/arabic-karshuni/*"
## upload new version
- scp -o 'StrictHostKeyChecking no' -r tido/dist/* $SSH_USER@$SSH_IP:~/$CI_COMMIT_REF_NAME/frontend/arabic-karshuni/
# syriac
## remove old version
- sed -i 's/textapi\/ahikar\/arabic-karshuni/textapi\/ahikar\/syriac/' tido/dist/index.html
- ssh -o 'StrictHostKeyChecking no' $SSH_USER@$SSH_IP "rm -rf ~/$CI_COMMIT_REF_NAME/frontend/syriac/*"
## upload new version
- scp -o 'StrictHostKeyChecking no' -r tido/dist/* $SSH_USER@$SSH_IP:~/$CI_COMMIT_REF_NAME/frontend/syriac/
# upload css
- scp -o 'StrictHostKeyChecking no' ahikar.css $SSH_USER@$SSH_IP:~/$CI_COMMIT_REF_NAME/frontend/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment