无法向GitHub上传Artifact:存储配额耗尽问题求助
问题描述
运行GitHub Actions工作流上传Artifact时失败,报错:
Error: Create Artifact Container failed: Artifact storage quota has been hit. Unable to upload any new artifacts
已将构建文件夹打包为zip后尝试上传,删除旧Artifact后问题仍未解决。工作流配置如下:
name: Build and Deploy My App on: push: branches: [master] workflow_dispatch: jobs: build: name: Creating Build ⚒ runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@main - name: setup Node Version To 16 uses: actions/setup-node@v2 with: node-version: '16.x' - name: Installing Packages 📦 run: npm install --legacy-peer-deps - name: 🔨 Build Project run: CI=false npm run build - name: zip the build folder run: zip release.zip ./build/** -r - name: Archive production artifact uses: actions/upload-artifact@v3 with: name: my-app-build path: release.zip deploy: name: Start The Deploying 🚀🤘 needs: build runs-on: ubuntu-latest steps: - name: Download artifact uses: actions/download-artifact@v3 with: name: my-app-build - name: unzip the build folder run: unzip my-app-build - name: All Good To Go ✔ start Sync files to hosting uses: SamKirkland/FTP-Deploy-Action@4.3.3 with: server: ${{ secrets.FTP_SERVER }} username: ${{ secrets.FTP_USERNAME }} password: ${{ secrets.FTP_PASSWORD }}
解决方法
- 核查仓库Artifact总存储配额:GitHub免费版仓库的Artifact存储限额为500MB,若总存储量超标,仅删除单个旧Artifact无法解决问题。需进入仓库
Settings > Actions > Artifacts and logs页面,查看当前存储占用情况,批量清理过期Artifact或工作流日志。 - 设置Artifact自动过期:在
upload-artifact步骤中添加retention-days参数,指定自动删除时间,避免存储长期占用。示例配置:- name: Archive production artifact uses: actions/upload-artifact@v3 with: name: my-app-build path: release.zip retention-days: 7 # 7天后自动删除该Artifact - 压缩Artifact体积:当前打包命令可能包含冗余文件(如
.map调试文件、未使用的静态资源),可在打包前清理build目录,或使用zip -9参数开启高压缩率,减少包体积。 - 跳过Artifact中转直接部署:由于build和deploy任务是关联执行的,可直接在build任务中完成打包后,将文件传递给deploy任务,无需通过Artifact存储。例如使用
actions/cache临时存储构建产物,或直接在job间共享文件,规避Artifact配额限制。
内容的提问来源于stack exchange,提问作者z Hunter
相关产品推荐
相关产品推荐

