我正试图使用GitHub Actions将我的项目部署到GitHub Pages,但我遇到了一个问题deploy-pages@v4找不到上传的工件。
Run actions/deploy-pages@v4
Fetching artifact metadata for "github-pages" in this workflow run
Found 0 artifact(s)
Error: Fetching artifact metadata failed. Is githubstatus.com reporting issues with API requests, Pages, or Actions? Please re-run the deployment at a later time.
Error: Error: No artifacts named "github-pages" were found for this workflow run. Ensure artifacts are uploaded with actions/upload-artifact@v4 or later.
at getArtifactMetadata (/home/runner/work/_actions/actions/deploy-pages/v4/src/internal/api-client.js:85:1)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Deployment.create (/home/runner/work/_actions/actions/deploy-pages/v4/src/internal/deployment.js:66:1)
at main (/home/runner/work/_actions/actions/deploy-pages/v4/src/index.js:30:1)
Error: Error: No artifacts named "github-pages" were found for this workflow run. Ensure artifacts are uploaded with actions/upload-artifact@v4 or later.
安装程序
我有两个工作流程:
CI-构建和;测试(构建项目并上传工件)
部署到GitHub Pages(在CI完成并部署到GitHub Page时运行)
CI-构建和;测试
name: CI - Build & Test
on:
push:
branches: ["master"]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
id: cache-web
uses: actions/cache@v4
with:
path: |
web/node_modules
key: ${{ runner.os }}-build-${{ hashFiles('**/web/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup Pages
uses: actions/configure-pages@v3
- name: wasm-pack
uses: jetli/[email protected]
with:
version: 'latest'
- run: wasm-pack build --target web --out-dir ../web/snake-game
working-directory: ./game
- run: npm install
working-directory: ./web
- run: npm run build
working-directory: ./web
- uses: dtolnay/[email protected]
- uses: Swatinem/rust-cache@v2
with:
cache-targets: false
- name: Tests
continue-on-error: true
run: cargo test --verbose
working-directory: ./game
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
working-directory: ./game
- name: push to codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./game/lcov.info
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: "./web/dist"
部署到GitHub页面
name: Deploy to GitHub Pages
on:
workflow_run:
workflows: ["CI - Build & Test"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
CI工作流日志
Run actions/upload-pages-artifact@v3
Run echo ::group::Archive artifact
Archive artifact
Run actions/upload-artifact@v4
With the provided path, there will be 1 file uploaded
Artifact name is valid!
Root directory input is valid!
Beginning upload of artifact content to blob storage
Uploaded bytes 307106
Finished uploading artifact content to blob storage!
SHA256 hash of uploaded artifact zip is bd7bd52796095adff4267943751a0a5b34d30033352cd4becf9f277f32e4e8e7
Finalizing artifact upload
Artifact github-pages.zip successfully finalized. Artifact ID 2638231538
Artifact github-pages has been successfully uploaded! Final size is 307106 bytes. Artifact ID is 2638231538
Artifact download URL:
任何帮助都将不胜感激!