From 35377652eff2ed1dbc40d21cde1be7774692ab1a Mon Sep 17 00:00:00 2001 From: Jonas Zohren <git-pbkyr@jzohren.de> Date: Sat, 25 Feb 2023 13:49:06 +0100 Subject: [PATCH] Add oh14.dev CI/CD --- .gitlab-ci.yml | 63 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94507ee..ed4f133 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,60 @@ -include: - - template: Security/License-Scanning.gitlab-ci.yml +stages: + - "build" + - "deploy" + +build_docker_main: + needs: [] + stage: "build" + image: + name: "gcr.io/kaniko-project/executor:debug" + entrypoint: [""] + script: + - "mkdir -p /kaniko/.docker" + - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json' + - "/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:commit-$CI_COMMIT_SHORT_SHA --destination $CI_REGISTRY_IMAGE:latest" + rules: + - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" + +build_docker_branches: + needs: [] + stage: "build" + image: + name: "gcr.io/kaniko-project/executor:debug" + entrypoint: [""] + script: + - "mkdir -p /kaniko/.docker" + - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json' + - "/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:commit-$CI_COMMIT_SHORT_SHA --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-latest" + rules: + - if: "$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH" pages: needs: [] - image: node:14-alpine - stage: deploy + stage: "deploy" + image: "node:18-alpine" script: - - npm install - - npm run build + - "npm install" + - "npm run build" artifacts: paths: - - public - only: - - master + - "public" + rules: + - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH" + +deploy_to_caprover: + needs: + - "build_docker_main" + stage: "deploy" + image: + name: "caprover/cli-caprover:latest" + entrypoint: [""] + variables: + # We don't need the files, just tell CapRover to use the built docker image: + GIT_STRATEGY: none + script: + - "caprover deploy -h https://captain.$CAPROVER_URL -a $CAPROVER_APP --imageName $CI_REGISTRY_IMAGE:commit-$CI_COMMIT_SHORT_SHA" + environment: + name: "production" + url: "https://swk-project-effort-estimation.oh14.dev/" + rules: + - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CAPROVER_URL && $CAPROVER_APP_TOKEN && $CAPROVER_APP" -- GitLab