提交 ca1423a5 authored 作者: 张伊明's avatar 张伊明

feat 更新ci配置

上级 36e079f6
流水线 #82 已失败
...@@ -3,9 +3,8 @@ stages: ...@@ -3,9 +3,8 @@ stages:
- deploy - deploy
cache: cache:
key: # cache:key 这里使用字符串,兼容性更好(部分 linter 不支持 key: { files: [...] })
files: key: "npm-cache-$CI_COMMIT_REF_SLUG"
- package-lock.json
paths: paths:
- .npm/ - .npm/
policy: pull-push policy: pull-push
...@@ -15,10 +14,8 @@ build_pre: ...@@ -15,10 +14,8 @@ build_pre:
image: node:20-bullseye image: node:20-bullseye
tags: tags:
- risk-monitor-frontend - risk-monitor-frontend
rules: only:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "pre"' - pre
when: on_success
- when: never
script: script:
- node -v - node -v
- npm -v - npm -v
...@@ -34,13 +31,10 @@ deploy_pre: ...@@ -34,13 +31,10 @@ deploy_pre:
image: alpine:3.20 image: alpine:3.20
tags: tags:
- risk-monitor-frontend - risk-monitor-frontend
rules: only:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "pre"' - pre
when: on_success dependencies:
- when: never - build_pre
needs:
- job: build_pre
artifacts: true
# 避免多次 deploy 争抢同一份 nginx 目录(极端情况下仍可串行化兜底) # 避免多次 deploy 争抢同一份 nginx 目录(极端情况下仍可串行化兜底)
resource_group: pre-nginx-deploy resource_group: pre-nginx-deploy
script: script:
...@@ -50,7 +44,7 @@ deploy_pre: ...@@ -50,7 +44,7 @@ deploy_pre:
LATEST_PIPELINE_ID="$( LATEST_PIPELINE_ID="$(
curl --silent --show-error --fail curl --silent --show-error --fail
--header "JOB-TOKEN: $CI_JOB_TOKEN" --header "JOB-TOKEN: $CI_JOB_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/pipelines?ref=pre&order_by=id&sort=desc&per_page=1" "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/pipelines?ref=pre&order_by=id&sort=desc&per_page=1"
| jq -r '.[0].id' | jq -r '.[0].id'
)" )"
- > - >
...@@ -63,7 +57,7 @@ deploy_pre: ...@@ -63,7 +57,7 @@ deploy_pre:
LATEST_PIPELINE_ID="$( LATEST_PIPELINE_ID="$(
curl --silent --show-error --fail curl --silent --show-error --fail
--header "JOB-TOKEN: $CI_JOB_TOKEN" --header "JOB-TOKEN: $CI_JOB_TOKEN"
"$CI_API_V4_URL/projects/$CI_PROJECT_ID/pipelines?ref=pre&order_by=id&sort=desc&per_page=1" "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/pipelines?ref=pre&order_by=id&sort=desc&per_page=1"
| jq -r '.[0].id' | jq -r '.[0].id'
)" )"
- > - >
...@@ -79,10 +73,10 @@ build_check: ...@@ -79,10 +73,10 @@ build_check:
image: node:20-bullseye image: node:20-bullseye
tags: tags:
- risk-monitor-frontend - risk-monitor-frontend
rules: only:
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH && $CI_COMMIT_REF_PROTECTED != "true"' - branches
when: on_success except:
- when: never - protected_branches
script: script:
- node -v - node -v
- npm -v - npm -v
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论