GitHub Actions:缺少必需的属性:shell

Thr*_*ror 32 java javadoc maven github-actions building-github-actions

介绍

我目前正在创建一个复合 GitHub Actions,它从 Java 项目构建 JavaDoc,并使用 GitHub Page 自动将其发布到静态页面。

有问题的

但是当我尝试运行它时出现此错误:

Current runner version: '2.287.1'
Operating System
Virtual Environment
Virtual Environment Provisioner
GITHUB_TOKEN Permissions
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'MathieuSoysal/Javadoc-publisher.yml@v2.0.2' (SHA:878c07f835dd9bcbb8800090d109c91b0f0d4581)
Error: MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
Error: MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
   at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml
Run Code Online (Sandbox Code Playgroud)

受影响的代码:

Current runner version: '2.287.1'
Operating System
Virtual Environment
Virtual Environment Provisioner
GITHUB_TOKEN Permissions
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'MathieuSoysal/Javadoc-publisher.yml@v2.0.2' (SHA:878c07f835dd9bcbb8800090d109c91b0f0d4581)
Error: MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
Error: MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
   at GitHub.DistributedTask.ObjectTemplating.TemplateValidationErrors.Check()
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml
Run Code Online (Sandbox Code Playgroud)

执行相关 GitHub Actions 的代码:

name: Deploy Javadoc
description: 'Automatically  generate your Javadoc from your maven project and deploy it with GitHub Page on javadoc branch.'
branding:
  icon: 'book-open'
  color: 'white'
inputs:
  java-version:  # version of java
    description: 'Java version inside your project'
    required: true
    default: '17'
  GITHUB_TOKEN: # GitHub Token
    description: 'The GitHub token the GitHub repository'
    required: true
  javadoc-branch: # branch where the javadoc is hosted
    description: 'Branch where the javadoc is hosted'
    required: true
    default: javadoc
 
runs:
  using: "composite"
  steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0
  - uses: actions/setup-java@v2
    with:
      java-version: ${{ inputs.java-version }}
      distribution: 'adopt'
  - name: Generate Javadoc
    run: mvn org.apache.maven.plugins:maven-javadoc-plugin:3.3.1:aggregate
  - name: Deploy 
    uses: JamesIves/github-pages-deploy-action@4.1.8
    with:
      GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
      BRANCH: ${{ inputs.javadoc-branch }}
      CLEAN: true
      FOLDER: target/site/apidocs
      TARGET_FOLDER: javadoc
Run Code Online (Sandbox Code Playgroud)

问题

有人有解决这个问题的想法吗?

Grz*_*ski 50

使用复合操作时,必须指定 shell。

\n

由于您没有在复合操作中指定运行程序类型,因此您需要为每个操作指定 shell。

\n

就你的情况而言,问题出在这一步,你需要shell: bash在这里添加:

\n
- name: Generate Javadoc\n  shell: bash\n  run: mvn org.apache.maven.plugins:maven-javadoc-plugin:3.3.1:aggregate\n
Run Code Online (Sandbox Code Playgroud)\n

文档:https://docs.github.com/en/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file

\n

  • @chantey https://docs.github.com/en/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file (2认同)
  • @GrzegorzKrukowski 该链接不会进入*为什么*。不幸的是,我发现 GitHub Actions 文档总体上缺乏 (2认同)