answer/ui/.gitlab-ci.yml

94 lines
2.0 KiB
YAML

include:
- project: 'segmentfault/devops/templates'
file:
- .deploy-cdn.yml
- .deploy-helm.yml
variables:
FF_USE_FASTZIP: 'true'
PROJECT_NAME: 'answer_static'
stages:
- install
- publish
- deploy
# 静态资源构建
install:
image: dockerhub.qingcloud.com/sf_base/node-build:14
stage: install
allow_failure: false
cache:
- key:
files:
- pnpm-lock.yml
paths:
- node_modules/
policy: pull-push
script:
- pnpm install
- if [ "$CI_COMMIT_BRANCH" = "dev" ]; then
sed -i "s/<projectName>/$PROJECT_NAME/g" .env.development;
sed -i "s/<version>/$CI_COMMIT_SHORT_SHA/g" .env.development;
pnpm run build:dev;
elif [ "$CI_COMMIT_BRANCH" = "main" ]; then
sed -i "s/<projectName>/$PROJECT_NAME/g" .env.test;
sed -i "s/<version>/$CI_COMMIT_SHORT_SHA/g" .env.test;
pnpm run build:test;
elif [ "$CI_COMMIT_BRANCH" = "release" ]; then
sed -i "s/<projectName>/$PROJECT_NAME/g" .env.production;
sed -i "s/<version>/$CI_COMMIT_SHORT_SHA/g" .env.production;
pnpm run build:prod;
fi
artifacts:
paths:
- build/
publish:cdn:dev:
extends: .deploy-cdn
stage: publish
only:
- dev
variables:
AssetsPath: ./build
Project: $PROJECT_NAME
Version: $CI_COMMIT_SHORT_SHA
Destination: dev
publish:cdn:test:
extends: .deploy-cdn
stage: publish
only:
- main
variables:
AssetsPath: ./build
Project: $PROJECT_NAME
Version: $CI_COMMIT_SHORT_SHA
Destination: test
publish:cdn:prod:
extends: .deploy-cdn
stage: publish
only:
- release
variables:
AssetsPath: ./build
Project: $PROJECT_NAME
Version: $CI_COMMIT_SHORT_SHA
Destination: prod
deploy:dev:
extends: .deploy-helm
stage: deploy
only:
- dev
needs:
- publish:cdn:dev
variables:
KubernetesCluster: dev
KubernetesNamespace: 'sf-test'
DockerTag: $CI_COMMIT_SHORT_SHA
ChartName: answer-web
InstallPolicy: replace