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

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

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

Closes #55

See merge request muni-kypo-crp/frontend-angular/components/kypo2-trainings-visualization-overview!56
parents 8f45faaa 7368115d
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ image: cypress/browsers:node12.18.0-chrome83-ff77 ...@@ -2,6 +2,7 @@ image: cypress/browsers:node12.18.0-chrome83-ff77
stages: stages:
- build - build
- auto-tag
- deploy - deploy
cache: cache:
...@@ -13,24 +14,6 @@ before_script: ...@@ -13,24 +14,6 @@ before_script:
- cp $NPMRC_PULL ~/.npmrc - cp $NPMRC_PULL ~/.npmrc
- npm ci --cache .npm --prefer-offline --ignore-scripts - npm ci --cache .npm --prefer-offline --ignore-scripts
buildExampleApp:
stage: build
cache:
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths:
- .npm/
policy: pull
script:
- npm run build-example-app
only:
- triggers
- branches
- tags
artifacts:
paths:
- ./dist
expire_in: 1 hour
buildLibrary: buildLibrary:
stage: build stage: build
cache: cache:
...@@ -43,45 +26,44 @@ buildLibrary: ...@@ -43,45 +26,44 @@ buildLibrary:
only: only:
- triggers - triggers
- branches - branches
- tags
artifacts: artifacts:
paths: paths:
- ./dist - ./dist
expire_in: 1 hour expire_in: 1 hour
except:
changes:
- "CHANGELOG.md"
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
editVersionAndDeploy: deploy:
stage: deploy stage: deploy
cache: cache:
key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR key: $CI_COMMIT_REF_SLUG-$CI_PROJECT_DIR
paths: paths:
- .npm/ - .npm/
policy: pull 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: 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 - cp $NPMRC_PULL ~/.npmrc
- npm run ci-build-and-pack - npm run ci-build-and-pack
- cp $NPMRC_PUSH ~/.npmrc - cp $NPMRC_PUSH ~/.npmrc
- npm run ci-publish-package - npm run ci-publish-package
- git push -o ci.skip
only: only:
- tags - tags
12.0.3 Update gitlab CI
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"build-library": "ng build --configuration production kypo2-trainings-visualization-overview-lib && cp ./projects/kypo2-trainings-visualization-overview-lib/src/lib/styles.css ./dist/kypo2-trainings-visualization-overview-lib", "build-library": "ng build --configuration production kypo2-trainings-visualization-overview-lib && cp ./projects/kypo2-trainings-visualization-overview-lib/src/lib/styles.css ./dist/kypo2-trainings-visualization-overview-lib",
"create-package": "cd dist/kypo2-trainings-visualization-overview-lib && npm pack", "create-package": "cd dist/kypo2-trainings-visualization-overview-lib && npm pack",
"build-and-pack": "npm install && npm run build-library && npm run create-package", "build-and-pack": "npm install && npm run build-library && npm run create-package",
"ci-update-version": "cd ./projects/kypo2-trainings-visualization-overview-lib/ && npm version $VERSION", "ci-update-version": "cd ./projects/kypo2-trainings-visualization-overview-lib/ && npm version $TAG_VERSION",
"ci-build-and-pack": "npm ci --cache .npm --prefer-offline && npm run build-library && npm run create-package", "ci-build-and-pack": "npm ci --cache .npm --prefer-offline && npm run build-library && npm run create-package",
"ci-publish-package": "cd dist/kypo2-trainings-visualization-overview-lib && npm publish" "ci-publish-package": "cd dist/kypo2-trainings-visualization-overview-lib && npm publish"
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment