如何修复 AWS code-build apt-get update exit status 100 for react application to upload on s3

How to fix the AWS code-build apt-get update exit status 100 for react application to upload on s3

我有 reactJs 应用程序并使用 AWS s3 部署静态站点。我已经为 CI/CD 设置了 AWS 代码构建。我正在使用 bitbucket,当任何 PR 合并到 master 分支 Web-hook 出现时触发反应应用程序构建并在 s3 上上传构建。

它在过去 2 年中运行良好,但在上一次构建中我遇到了以下错误。

W: GPG error: https://dl.yarnpkg.com/debian stable InRelease: The following signatures were invalid: EXPKEYSIG 23E7166788B63E1E Yarn Packaging yarn@dan.cx E: The repository 'https://dl.yarnpkg.com/debian stable InRelease' is not signed.

[Container] 2021/02/04 07:39:02 Command did not exit successfully apt-get update exit status 100 [Container] 2021/02/04 07:39:02 Phase complete: INSTALL State: FAILED [Container] 2021/02/04 07:39:02 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: apt-get update. Reason: exit status 100

这是完整的日志输出。

这里是 buildspec.yml 文件

# aws codebuild for React and deployment to S3
version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 10
    commands:
      - echo Installing build dependencies...
      - apt-get update
      - apt-get install -y sshpass zip unzip
  pre_build:
    commands:
      - echo Build started on `date`
      - echo Installing source NPM dependencies...
      - npm ci
      - cp src/gatsby-overrides/gatsby-sharp.js node_modules/gatsby-plugin-sharp/index.js
      - cp src/gatsby-overrides/gatsby-image.js node_modules/gatsby-image/index.js
  build:
    commands:
      - npm run build
      - chmod u+x script.sh
      - ./script.sh
    finally:
      - echo Build completed on `date`
cache:
  paths:
    - 'public/**/*'

它在第 82 行抱怨的签名密钥,在 apt 更新之前安装它会发生什么?像这里建议的那样:https://github.com/yarnpkg/yarn/issues/7866

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -

无需 sudo 即可为我工作。以下命令有效:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -