Gitlab CI:为什么我在尝试定义页面阶段时出现错误?

Gitlab CI: why do I get an error when I try to define the pages stage?

我正在尝试在 Gitlab 上发布一个 create-react-app,使用它的 CI。

这是我的 .gitlab-ci.yml 文件:

stages:
  - build
  - pages

build:
  image: node:16
  stage: build
  script:
    - npm install
    - npm build
  artifacts:
    paths:
      - build/

pages:
  image: alpine:latest
  stage: deploy
  variables:
    GIT_STRATEGY: none        # Do not clone git repo
  script:
    - mv build public         
  artifacts:
    paths:
      - public  
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

但不幸的是我得到了这个错误:

This GitLab CI configuration is invalid: pages job: chosen stage does not exist; available stages are .pre, build, pages, .post.

我的配置有什么问题?

你需要改变你的阶段。

你有:

stages:
  - build
  - pages

但定义:

pages:
  image: alpine:latest
  stage: deploy

需要匹配的舞台:

stages:
  - build
  - deploy <-------