Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Pipeline improve production deployment

Michal Rutka987ba359d132
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 02fcefb87..0db90ec5e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,6 +12,11 @@ variables:
DEPLOYMENT_PORT: 2222
DAST_WEBSITE: https://staging.${PROJECT_NAME}.openremote.io
+workflow:
+ rules:
+ - if: $CI_COMMIT_BRANCH != "master"
+ when: never
+
stages:
- build
- build_fail
diff --git a/gitlab-ci/gitlab-ci-submodule.yml b/gitlab-ci/gitlab-ci-submodule.yml
index 61a666261..2d0cab069 100644
--- a/gitlab-ci/gitlab-ci-submodule.yml
+++ b/gitlab-ci/gitlab-ci-submodule.yml
@@ -5,22 +5,29 @@ default:
- docker:dind # Docker in docker service
variables:
- ## Following 3 varaiables should be defined as GitLab CI/CD variables
+ ## Following 3 variables should be defined as GitLab CI/CD variables
#PROJECT_NAME:
#DEPLOYMENT_HOST_USER:
#DEPLOYMENT_PORT:
GIT_SUBMODULE_STRATEGY: normal
DAST_WEBSITE: https://staging.${PROJECT_NAME}.${DOMAIN}
+workflow:
+ rules:
+ - if: $CI_COMMIT_BRANCH != "master"
+ when: never
+
stages:
- - build
+ - build_staging
- build_fail
- test
- deploy
- dast
+ - build_production
+ - deploy_production
+ - deploy_production_clean
.build_template: &build_definition
- stage: build
variables:
SCAN_IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
MANAGER_IMAGE_TAG: $CI_REGISTRY_IMAGE/manager:$CI_ENVIRONMENT_SLUG
@@ -63,26 +70,16 @@ stages:
- docker push "$CI_REGISTRY_IMAGE/keycloak:$CI_ENVIRONMENT_SLUG-$CI_COMMIT_TAG"
- fi
-build production docker images:
- rules:
- - if: $CI_COMMIT_BRANCH == "master"
- when: manual
- allow_failure: true
- environment: production
- <<: *build_definition
-
build staging docker images:
+ stage: build_staging
rules:
- - if: $CI_COMMIT_BRANCH != "master"
- when: never
- if: $CI_COMMIT_MESSAGE !~ /skip-build/
environment: staging
<<: *build_definition
build manually staging docker images:
+ stage: build_staging
rules:
- - if: $CI_COMMIT_BRANCH != "master"
- when: never
- if: $CI_COMMIT_MESSAGE =~ /skip-build/
when: manual
allow_failure: true
@@ -111,8 +108,6 @@ email failed pipeline:
-e "SMTP_PASSWORD=$SMTP_PASSWORD"
--rm python:3 python aws_mail.py
when: on_failure
- only:
- - master
include:
- template: Container-Scanning.gitlab-ci.yml
@@ -131,7 +126,6 @@ include:
- alias SCP="scp -p -r -P $DEPLOYMENT_PORT"
.deploy_template: &deploy_definition
- stage: deploy
before_script:
- *ssh_config
script:
@@ -175,9 +169,7 @@ include:
expire_in: 1 week
deploy staging:
- rules:
- - if: $CI_COMMIT_BRANCH == "master"
- when: on_success
+ stage: deploy
variables:
DEPLOYMENT_HOST: ${CI_ENVIRONMENT_SLUG}.${PROJECT_NAME}.${DOMAIN}
SETUP_WIPE_CLEAN_INSTALL: 'true'
@@ -186,11 +178,14 @@ deploy staging:
url: https://${CI_ENVIRONMENT_SLUG}.${PROJECT_NAME}.${DOMAIN}
<<: *deploy_definition
+build production docker images:
+ stage: build_production
+ when: manual
+ environment: production
+ <<: *build_definition
+
deploy production:
- rules:
- - if: $CI_COMMIT_BRANCH == "master"
- when: manual
- allow_failure: true
+ stage: deploy_production
variables:
DEPLOYMENT_HOST: ${PROJECT_NAME}.${DOMAIN}
SETUP_WIPE_CLEAN_INSTALL: 'false'
@@ -198,3 +193,14 @@ deploy production:
name: production
url: https://${PROJECT_NAME}.${DOMAIN}
<<: *deploy_definition
+
+deploy production clean:
+ stage: deploy_production_clean
+ when: on_failure
+ variables:
+ DEPLOYMENT_HOST: ${PROJECT_NAME}.${DOMAIN}
+ SETUP_WIPE_CLEAN_INSTALL: 'true'
+ environment:
+ name: production
+ url: https://${PROJECT_NAME}.${DOMAIN}
+ <<: *deploy_definition