add staging build step

This commit is contained in:
cedricve
2021-07-15 12:47:59 +02:00
parent 9ffb937980
commit 51d871236e
3 changed files with 27 additions and 7 deletions

View File

@@ -11,20 +11,35 @@ variables:
REGISTRY: registry.gitlab.com/kerberos-io/${ARTIFACT_NAME} REGISTRY: registry.gitlab.com/kerberos-io/${ARTIFACT_NAME}
stages: stages:
- pages - build-staging # Staging environment -> develop
- docker - build-production # Production environment -> master
- kubernetes-staging - docker # All branches
- kubernetes-production - kubernetes-staging # Staging environment -> develop
- kubernetes-production # Production environment -> master
pages: build-staging:
image: node:10.22.1 image: node:10.22.1
stage: pages stage: build
script:
- yarn
- yarn run build-staging
artifacts:
paths:
- public
except:
- master
build-production:
image: node:10.22.1
stage: build
script: script:
- yarn - yarn
- yarn run build - yarn run build
artifacts: artifacts:
paths: paths:
- public - public
only:
- master
docker: docker:
image: docker:stable image: docker:stable
@@ -36,6 +51,7 @@ docker:
- docker build --build-arg gitlab_id=${gitlab_id} --build-arg gitlab_token=${gitlab_token} -t $CI_REGISTRY/$REPO_NAME:$CI_VERSION . - docker build --build-arg gitlab_id=${gitlab_id} --build-arg gitlab_token=${gitlab_token} -t $CI_REGISTRY/$REPO_NAME:$CI_VERSION .
- docker push $CI_REGISTRY/$REPO_NAME:$CI_VERSION - docker push $CI_REGISTRY/$REPO_NAME:$CI_VERSION
kubernetes-staging: kubernetes-staging:
image: registry.cn-hangzhou.aliyuncs.com/haoshuwei24/kubectl:1.16.6 image: registry.cn-hangzhou.aliyuncs.com/haoshuwei24/kubectl:1.16.6
stage: kubernetes-staging stage: kubernetes-staging
@@ -43,6 +59,8 @@ kubernetes-staging:
name: staging name: staging
script: script:
- kubectl patch deployment kerberos-documentation --patch="{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"kerberos-documentation\",\"image\":\"${REGISTRY}:${CI_VERSION}\"}]}}}}" -n kerberos-ecosystem - kubectl patch deployment kerberos-documentation --patch="{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"kerberos-documentation\",\"image\":\"${REGISTRY}:${CI_VERSION}\"}]}}}}" -n kerberos-ecosystem
except:
- master
kubernetes-production: kubernetes-production:
image: registry.cn-hangzhou.aliyuncs.com/haoshuwei24/kubectl:1.16.6 image: registry.cn-hangzhou.aliyuncs.com/haoshuwei24/kubectl:1.16.6

View File

@@ -0,0 +1 @@
env = "staging"

View File

@@ -19,7 +19,8 @@
"prestart": "npm run clean", "prestart": "npm run clean",
"start": "hugo server --bind=0.0.0.0 --disableFastRender", "start": "hugo server --bind=0.0.0.0 --disableFastRender",
"prebuild": "npm run clean", "prebuild": "npm run clean",
"build": "hugo --gc --minify && npm run build:functions", "build": "hugo --gc --minify --environment production && npm run build:functions",
"build-staging": "hugo --gc --minify --environment staging && npm run build:functions",
"build:functions": "netlify-lambda build assets/lambda", "build:functions": "netlify-lambda build assets/lambda",
"build:preview": "npm run build -D -F", "build:preview": "npm run build -D -F",
"clean": "rimraf public resources functions", "clean": "rimraf public resources functions",