简体   繁体   English

Github 部署到 s3 存储桶的操作工作流问题

[英]Github Action workflow issue for deploying to s3 bucket

I am getting the following error when running a Github Action for deploying a React website to an S3 bucket:运行 Github 操作以将 React 网站部署到 S3 存储桶时出现以下错误:

    at generateRegionPrefix (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/region_config.js:6:22)
    at derivedKeys (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/region_config.js:13:22)
    at Object.configureEndpoint (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/region_config.js:38:14)
    at features.constructor.initialize (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/service.js:72:45)
    at features.constructor.Service [as constructor] (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/service.js:59:10)
    at features.constructor (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/util.js:637:24)
    at new features.constructor (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/util.js:637:24)
    at features.constructor.Service [as constructor] (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/service.js:50:17)
    at new features.constructor (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/aws-sdk/lib/util.js:637:24)
    at _callee3$ (/home/runner/.npm/_npx/55947e5ced8dc5f0/node_modules/s3-deploy/dist/deploy.js:406:22)

The workflow.yml file: workflow.yml 文件:

name: S3 Deploy Workflow
on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]
  workflow_dispatch:
jobs:
  run:
    runs-on: ubuntu-latest
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    steps:
      - uses: actions/checkout@v3

      - name: Installs dependencies
        run: yarn
        
      - name: Build
        run: yarn build

      - name: Deploy
        uses: reggionick/s3-deploy@v3
        with:
          folder: build
          bucket: ${{ secrets.S3_BUCKET }}
          bucket-region: ${{ secrets.S3_BUCKET_REGION }}
          dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
          invalidation: /
          delete-removed: true
          no-cache: true
          private: true
          filesToInclude: ".*/*,*/*,**"

The region being used is ap-southeast-2.使用的区域是 ap-southeast-2。 Has anyone came across this issue before and if so how did you fix it?以前有没有人遇到过这个问题,如果遇到过,您是如何解决的?

Thanks in advance.提前致谢。

I have used this action to setup aws credentials我已经使用此操作来设置 aws 凭据

      - name: Set AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.S3_BUCKET_REGION }}

The complete workflow完整的工作流程

name: S3 Deploy Workflow
on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]
  workflow_dispatch:
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Installs dependencies
        run: yarn
        
      - name: Build
        run: yarn build

      - name: Set AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.S3_BUCKET_REGION }}

      - name: Deploy
        uses: reggionick/s3-deploy@v3
        with:
          folder: build
          bucket: ${{ secrets.S3_BUCKET }}
          bucket-region: ${{ secrets.S3_BUCKET_REGION }}
          dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
          invalidation: /
          delete-removed: true
          no-cache: true
          private: true
          filesToInclude: ".*/*,*/*,**"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM