From 09332786bf8dc63bbb3645cb0cbf6bfe57657cce Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos <dimit.giannopoulos@upnet.gr> Date: Tue, 19 Dec 2023 11:53:43 +0000 Subject: [PATCH] added angular build and branch logic --- ci-templates/build.yml | 15 +++++++++++++-- ci-templates/build_unprotected.yml | 29 +++++++++++++++++++++++++++++ ci-templates/default.yml | 24 +++++++++++++++++------- ci-templates/dependencies.yml | 1 - 4 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 ci-templates/build_unprotected.yml diff --git a/ci-templates/build.yml b/ci-templates/build.yml index 7c2be0d..7571d5b 100644 --- a/ci-templates/build.yml +++ b/ci-templates/build.yml @@ -1,5 +1,5 @@ .maven_build: - extends: .default + extends: .default_protected stage: build image: maven:3.9.5-ibm-semeru-17-focal script: @@ -9,7 +9,7 @@ - target/ .docker_build: - extends: .default + extends: .default_protected stage: build image: name: gcr.io/kaniko-project/executor:debug @@ -21,3 +21,14 @@ echo "Pushing Docker image with tag 'latest'" /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:latest" fi + +.angular_build 2/2: + extends: .default_protected + stage: build + image: node:latest + script: + - npm install + - npm run build -- --prod + artifacts: + paths: + - dist/ diff --git a/ci-templates/build_unprotected.yml b/ci-templates/build_unprotected.yml new file mode 100644 index 0000000..544b9e0 --- /dev/null +++ b/ci-templates/build_unprotected.yml @@ -0,0 +1,29 @@ +.maven_build: + extends: .default_unprotected + stage: build + image: maven:3.9.5-ibm-semeru-17-focal + script: + - mvn install -s ci_settings.xml -DskipTests + artifacts: + paths: + - target/ + +.docker_build: + extends: .default_unprotected + stage: build + image: + name: gcr.io/kaniko-project/executor:debug + entrypoint: [""] + script: + - /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/Dockerfile" --destination "${CI_REGISTRY_IMAGE}:$APP_VERSION" --no-push + +.angular_build 2/2: + extends: .default_unprotected + stage: build + image: node:latest + script: + - npm install + - npm run build -- --dev + artifacts: + paths: + - dist/ diff --git a/ci-templates/default.yml b/ci-templates/default.yml index e27f757..f21a955 100644 --- a/ci-templates/default.yml +++ b/ci-templates/default.yml @@ -5,18 +5,28 @@ stages: - post - security +# Default configuration for all jobs .default: - variables: - DEFAULT_TAG: "1.2.0-SNAPSHOT" before_script: - | if [ "$CI_COMMIT_REF_NAME" = "main" ] && [ -n "$CI_COMMIT_TAG" ]; then export APP_VERSION=$CI_COMMIT_TAG elif [ "$CI_COMMIT_REF_NAME" = "develop" ]; then export APP_VERSION="develop" - else - export APP_VERSION=$DEFAULT_TAG fi - # rules: - # - if: $CI_COMMIT_REF_NAME == "main" - # - if: $CI_COMMIT_REF_NAME == "develop" + +# Configuration for jobs on protected branches +.default_protected: + extends: .default + rules: + - if: $CI_COMMIT_REF_PROTECTED == "true" + +# Configuration for jobs on unprotected branches +.default_unprotected: + # extends: .default + variables: + APP_VERSION: $CI_COMMIT_REF_NAME + rules: + - if: $CI_COMMIT_REF_PROTECTED != "true" + artifacts: + expire_in: 1 day diff --git a/ci-templates/dependencies.yml b/ci-templates/dependencies.yml index 8ec3c9f..26f6004 100644 --- a/ci-templates/dependencies.yml +++ b/ci-templates/dependencies.yml @@ -1,5 +1,4 @@ install_node_dependencies: - stage: install image: node:latest script: - npm install -- GitLab