on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
- name: Archive Production Artifact
uses: actions/upload-artifact@master
with:
name: build
path: build
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Download Artifact
uses: actions/download-artifact@master
with:
name: build
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
现在这是gtihub操作工作流程,它正在执行构建作业而没有错误,但是在部署中会出现错误 this is the error image 它显示的错误是错误:指定的公共目录“ build”不存在,无法将托管部署到站点Landing-page-design-1我一直关注从工作流复制到的博客,除了某些方面,我做的所有事情都一样很明显的项目详细信息,请帮助我解决为什么会发生此错误以及如何解决该问题
答案 0 :(得分:1)
您可能正在将工件解压缩到根目录而不是build/
。
我猜您在使用download-artifact@v1
时为download-artifact@v2
写了一篇文章(因为master
当前指向那里)。 here讨论了两者之间的差异。
在下载工件之后,我首先要验证发生了什么
- name: Display directory structure
run: ls -R
shell: bash
如果文件确实位于根目录中,则添加path
应该可以解决此问题。
- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: build
path: build
PS:不建议使用actions/<name>@master
,因为如果同一动作在两个版本之间的行为不同,它总是会导致问题……例如actions/download-artifact
;)
答案 1 :(得分:0)
您也可以尝试使用firebase-publish-react简化工作流程文件
这个特殊的动作插件负责内部构建应用程序,并且可以重复使用先前步骤中的构建目录。
- name: Deploy to Firebase
uses: mohammed-atif/firebase-publish-react@v1.0
with:
firebase-token: ${{ secrets.FIREBASE_TOKEN }}