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

无法运行GitHub Action:复合Action配置报错求助

解决GitHub复合Action运行脚本的配置错误

我创建了一个PHPUnit 5.6的复合GitHub Action,包含以下文件:

原action.yml代码

name: PHPUnit 5.6
description: Run your PHPUnit tests with php 5.6 in your Github Actions.
inputs:
  coverage_html:
    description: Generate code coverage report in HTML format
    required: false

  coverage_text:
    description: Generate code coverage report in text format (true to output to console, path to output to file)
    required: false

  coverage_xml:
    description: Generate code coverage report in PHPUnit XML format
    required: false

  args:
    description: Extra arguments to pass to the phpunit binary
    required: false
runs:
  using: "composite"
  steps:
    - run: entrypoint.sh
      shell: bash

原entrypoint.sh代码

docker ps

运行时出现以下错误:

Error: nguyenthemanh2601/phpunit/v1/action.yml (Line: 22, Col: 7): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory
Error: nguyenthemanh2601/phpunit/v1/action.yml (Line: 22, Col: 7): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory
Error: System.ArgumentException: Unexpected type '' encountered while reading 'steps item uses'. The type 'StringToken' was expected.

问题原因

复合Action的默认工作目录是调用该Action的仓库根目录,而非Action自身的目录,直接写entrypoint.sh会找不到脚本;同时缺少必要的路径配置,导致GitHub Actions无法正确解析步骤。

解决方案

修改action.yml

更新步骤部分,指定脚本的完整路径并添加可执行权限:

name: PHPUnit 5.6
description: Run your PHPUnit tests with php 5.6 in your Github Actions.
inputs:
  coverage_html:
    description: Generate code coverage report in HTML format
    required: false

  coverage_text:
    description: Generate code coverage report in text format (true to output to console, path to output to file)
    required: false

  coverage_xml:
    description: Generate code coverage report in PHPUnit XML format
    required: false

  args:
    description: Extra arguments to pass to the phpunit binary
    required: false
runs:
  using: "composite"
  steps:
    - name: Execute entrypoint script
      run: |
        chmod +x ${{ github.action_path }}/entrypoint.sh
        ${{ github.action_path }}/entrypoint.sh
      shell: bash
  • ${{ github.action_path }}是GitHub Actions内置变量,指向当前复合Action所在的目录,确保能正确找到entrypoint.sh
  • 先执行chmod +x赋予脚本可执行权限,避免权限报错

优化entrypoint.sh

在脚本开头添加shebang声明,明确指定执行shell:

#!/bin/bash
docker ps

内容的提问来源于stack exchange,提问作者The Manh Nguyen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.24 06:15:21