You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过GitHub Action将WPack.io生成的WordPress主题.zip设为Release资产?

解决GitHub Actions中WPack.io归档文件路径问题

你的核心问题是WPack.io生成的主题归档文件存放在/builds目录下,但GitHub Actions的Release步骤指定读取顶层的同名zip文件。下面提供两种直接的解决方式:


方式一:移动归档文件到顶层

在Run WPack Archive步骤之后、Release步骤之前,新增移动文件的步骤,将/builds下的归档文件移到仓库根目录:

- name: 移动归档文件到顶层
  run: |
    # 将builds目录下的theme.zip移动到根目录,并重命名为仓库名称的zip(匹配Release步骤参数)
    mv builds/theme.zip ./${{ github.event.repository.name }}.zip

修改后的完整Workflow配置:

# This is a basic workflow to help you get started with Actions
name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      - name: Install dependencies
        run: |
          npm install

      - name: Run WPack Build
        run: |
          npm run build
          
      - name: Run WPack Archive
        run: |
          npm run archive

      - name: 移动归档文件到顶层
        run: |
          mv builds/theme.zip ./${{ github.event.repository.name }}.zip

      - name: Release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          files: ${{ github.event.repository.name }}.zip
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

方式二:直接指定归档文件路径

无需移动文件,直接在Release步骤的files参数里填写/builds目录下的文件路径:

- name: Release
  uses: softprops/action-gh-release@v1
  if: startsWith(github.ref, 'refs/tags/')
  with:
    files: builds/theme.zip
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

两种方式都能实现将归档文件作为Release资产上传,根据你的偏好选择即可。

内容的提问来源于stack exchange,提问作者Cole

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 12:31:25