1

摘要:我正在尝试使用 CircleCI orb 将静态站点 (gatsby) 自动部署到 S3 存储桶,但我不断收到以下错误:

#!/bin/bash -eo pipefail aws configure set aws_access_key_id
$AWS_ACCESS_KEY_ID
--profile default 找不到配置文件 (*******) 退出代码退出状态 255 CircleCI 收到退出代码 255

我已经在我在 CircleCI 中设置的 AWS 上下文中检查了 AWS_ACCESS_KEY_ID 的环境变量。我在circleci官方论坛上搜索了一些答案,我尝试了这里提供的建议https://discuss.circleci.com/t/you-must-specify-a-region-you-can-also-configure-your-region -by-running-aws-configure-exited-with-code-255/14392,但仍然没有解决问题的进展。如果有人能帮帮我,我将不胜感激。

另外,这是我的 CircleCI config.yml文件

version: 2.1

executors:
  node_executor:
    docker:
      - image: circleci/node:12.19.1

orbs:
  aws-cli: circleci/aws-cli@1.3.1
  aws-s3: circleci/aws-s3@2.0.0

jobs:

  setup_gatsby:

    executor: node_executor
    working_directory: ~/application
    steps:
      - checkout
      - run:
          name: Update npm
          command: "sudo npm install -g npm@latest"
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          name: Restoring package.json cache
      - run:
          name: Install npm
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          name: Saving package.json cache
          paths:
            - node_modules
      - save_cache:
          key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
          paths:
            - ~/application
  build_gatsby:
    executor: node_executor
    working_directory: ~/application
    steps:
      - restore_cache:
          key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Build
          command: |
            npm run clean
            npm run build
      - save_cache:
          key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
          paths:
            - ~/application
  deploy_gatsby:
    executor: aws-cli/default
    working_directory: ~/application/public
    steps:
      - restore_cache:
          key: v1-repo-{{ .Environment.CIRCLE_SHA1 }}
      - aws-s3/sync:
          from: .
          to: AWS_S3_BUCKET_NAME 
          arguments: |
            --acl public-read \
            --cache-control "max-age=86400"
          aws-access-key-id: AWS_ACCESS_KEY_ID
          aws-secret-access-key: AWS_SECRET_ACCESS_KEY
          aws-region: AWS_DEFAULT_REGION

workflows:
  version: 2.1
  build:
    jobs:
      - setup_gatsby
      - build_gatsby:
          context: aws
          requires:
            - setup_gatsby
          filters:
            branches:
              only:
                - master
      - deploy_gatsby:
          context: aws
          requires:
            - build_gatsby
          filters:
            branches:
              only:
                - master

在此处输入图像描述

4

0 回答 0