Skip to content
Snippets Groups Projects
Commit 36748ad7 authored by Erik Kočamba's avatar Erik Kočamba
Browse files

Merge branch '16-simplify-gitlab-ci-cd-using-csirt-mu-docker-image' into 'master'

Resolve "Simplify Gitlab CI/CD using CSIRT-MU Docker image"

Closes #16

See merge request muni-kypo-crp/frontend-angular/models/kypo2-angular-topology-model!20
parents 4f332b15 8fcde06d
Branches
Tags
No related merge requests found
......@@ -3,6 +3,7 @@ image: cypress/browsers:node12.18.0-chrome83-ff77
stages:
- codeStyle
- build
- auto-tag
- deploy
cache:
......@@ -26,7 +27,9 @@ codeStyle:
only:
- triggers
- branches
- tags
except:
changes:
- "CHANGELOG.md"
buildLibrary:
stage: build
......@@ -40,46 +43,44 @@ buildLibrary:
only:
- triggers
- branches
- tags
artifacts:
paths:
- ./dist
expire_in: 1 hour
except:
changes:
- "CHANGELOG.md"
editVersionAndDeploy:
auto-tag:
image: 'registry.gitlab.ics.muni.cz:443/csirt-mu-devel/csirt-mu-devel-artifact-repository/docker-common-ci:v0.1.6'
variables:
GIT_STRATEGY: clone
stage: auto-tag
script:
- source /app/export-tag-vars.sh VERSION.txt
- echo $TAG_VERSION && echo $TAG_MESSAGE
- /app/import-ssh-key.sh
- /app/prepare-git.sh
- /app/set-version-angular.sh
- /app/create-changelog.sh
- /app/tag-and-push.sh
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
changes:
- VERSION.txt
deploy:
stage: deploy
cache:
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths:
- .npm/
policy: pull
before_script:
# get tag version
- export VERSION=$(if [[ "$CI_COMMIT_TAG" == "" ]]; then echo "GitLab tag is missing!"; else echo $CI_COMMIT_TAG | cut -c 2-; fi)
- echo $VERSION
# ssh config
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh -o 'StrictHostKeyChecking no' git@gitlab.ics.muni.cz
# git config
- git config --global user.email "$GIT_SERVICE_USER_EMAIL"
- git config --global user.name "$GIT_SERVICE_USER_NAME"
- git remote set-url origin "$REPOSITORY_SSH_URL"
- git fetch
- git checkout master
- git pull
script:
- npm run ci-update-version
- git commit -am "Update project package.json version based on GitLab tag. Done by CI"
- cp $NPMRC_PULL ~/.npmrc
- npm run ci-build-and-pack
- cp $NPMRC_PUSH ~/.npmrc
- npm run ci-publish-package
- git push -o ci.skip
only:
- tags
12.0.2 Update gitlab CI
\ No newline at end of file
......@@ -13,7 +13,7 @@
"build-library": "ng build --configuration production kypo2-topology-graph-model",
"create-package": "cd dist/kypo2-topology-graph-model && npm pack",
"build-and-pack": "npm install && npm run build-library && npm run create-package",
"ci-update-version": "cd ./projects/kypo2-topology-graph-model/ && npm version $VERSION",
"ci-update-version": "cd ./projects/kypo2-topology-graph-model/ && npm version $TAG_VERSION",
"ci-build-and-pack": "npm ci --cache .npm --prefer-offline && npm run build-library && npm run create-package",
"ci-publish-package": "cd dist/kypo2-topology-graph-model && npm publish"
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment