azure - gitlab 管道到 azure 静态 Web 应用程序似乎不起作用

标签 azure gitlab gitlab-ci-runner azure-static-web-app

我正在尝试采用一个非常普通的 create-react 应用程序,并通过 Gitlab 管道将其部署到 Azure 静态 Web 应用程序。

project structure

我已经像这样创建了 .yml 文件

stages:
  - build
  - deploy

variables:
  API_TOKEN: $DEPLOYMENT_TOKEN
  APP_PATH: '$CI_PROJECT_DIR'
  OUTPUT_PATH: '$CI_PROJECT_DIR/build/'
  VERBOSE: 'true'

build:
  stage: build
  image: node:18.15.0-bullseye
  script:
    - npm install
    - npm run build
  artifacts:
    paths:
      - $OUTPUT_PATH

deploy:
  stage: deploy
  image: registry.gitlab.com/static-web-apps/azure-static-web-apps-deploy
  script:
    - echo "App deployed successfully."

并且根本没有报告任何错误,但 azure 站点没有任何反应。当我查看它时,除了“您的 Azure 静态 Web 应用程序已上线并正在等待您的内容”消息之外,我仍然看不到任何内容。管道构建上的日志看起来不错...但它好像没有上传我的工件?我不知道如何获取更多诊断信息。

构建日志

Compiled successfully.
File sizes after gzip:
  46.61 kB  build\static\js\main.5a84f9dc.js
  1.79 kB   build\static\js\787.d8457f89.chunk.js
  541 B     build\static\css\main.073c9b0a.css
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
You may serve it with a static server:
  npm install -g serve
  serve -s build
Find out more about deployment here:
  https://cra.link/deployment
Uploading artifacts for successful job
00:03
Version:      16.3.1
Git revision: d240d5bb
Git branch:   16-3-stable
GO version:   go1.20.5
Built:        2023-09-14T23:38:58+0000
OS/Arch:      windows/amd64
Uploading artifacts...
Runtime platform                                    arch=amd64 os=windows pid=3776 revision=d240d5bb version=16.3.1
C:\Gitlab-Runner\builds\RNyC64A_\0\XXXX\secure-web-app/build/: found 20 matching artifact files and directories 
Uploading artifacts as "archive" to coordinator... 201 Created  id=20386 responseStatus=201 Created token=3stNxfN_
Cleaning up project directory and file based variables
00:02
Job succeeded

部署日志

Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell (powershell) executor...
Preparing environment
00:01
Running on XXXXXXX...
Getting source from Git repository
00:32
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in C:/Gitlab-Runner/builds/RNyC64A_/0/XXXX/secure-web-app/.git/
Checking out c333aa81 as detached HEAD (ref is master)...
Removing build/
Removing node_modules/
git-lfs/3.0.2 (GitHub; windows amd64; go 1.17.2)
Skipping Git submodules setup
Downloading artifacts
00:03
Version:      16.3.1
Git revision: d240d5bb
Git branch:   16-3-stable
GO version:   go1.20.5
Built:        2023-09-14T23:38:58+0000
OS/Arch:      windows/amd64
Downloading artifacts for build (20386)...
Runtime platform                                    arch=amd64 os=windows pid=26872 revision=d240d5bb version=16.3.1
Downloading artifacts from coordinator... ok        host=git.xxxx.com id=20386 responseStatus=200 OK token=3stNxfN_
Executing "step_script" stage of the job script
00:01
$ echo "App deployed successfully."
App deployed successfully.
Cleaning up project directory and file based variables
00:01
Job succeeded

最佳答案

我的 yml 文件没有任何问题。问题实际上是运行器本身设置为“shell”模式,并且您是否需要使用“docker”模式。否则,部署到 Azure 静态 Web 应用程序的镜像将无法工作

关于azure - gitlab 管道到 azure 静态 Web 应用程序似乎不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77134705/

相关文章:

gitlab-ci - 如果没有工件,如何使任务失败

sql-server - 了解使用 Azure 数据工厂的专用终结点的托管 VNet

将项目添加到服务总线的 Azure API 管理策略 - 应返回错误

centos - 无法在 Gitlab 上创建项目或添加 ssh key

kubernetes - 使用带有 gitlab runner helm chart 和 ci job 的 helm 拉取私有(private)注册表镜像时访问被拒绝

docker - 使用Dockerfile在700(drwx ------)目录中创建文件

asp.net-mvc-4 - 我发布到 azure 后,与 MVC4 bundle 不起作用

azure - Windows HPC 服务器和 Azure

docker - `docker pull` 从私有(private) gitlab 注册表返回 `denied: access forbidden`

git - 我如何使用 git checkout 功能?