我正在尝试使用 CICD 原则建立一个反应网站。我可以在本地运行它,使用“npm run build”来获取构建文件夹,当我手动将文件推送到 S3 时,网站运行良好。但是,当我尝试通过 github 操作运行构建和部署时,upload-artifacts 步骤会给出以下警告:'警告:未找到具有提供的路径的文件:build. 不会上传任何工件。显然,部署作业随后失败,因为它找不到任何要下载的工件。为什么会发生这种情况?构建文件夹肯定是创建的,因为在构建之后运行 ls 将其列为当前工作目录中的文件夹之一。
name: frontend_actions
on:
workflow_dispatch:
push:
paths:
- 'frontend/'
- '.github/workflows/frontend_actions.yml'
branches:
- master
defaults:
run:
working-directory: frontend
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: npm install
run: npm install
- name: npm build
run: npm run build
env:
CI: false
- name: Upload Artifact
uses: actions/upload-artifact@master
with:
name: build
path: build
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: build
path: build
- name: Deploy to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2' # optional: defaults to us-east-1
SOURCE_DIR: 'build' # optional: defaults to entire repository