github-actions - 将 GitHub Action 发布到 Marketplace:意外值“步骤”
问题描述
我在一个项目中使用了下面的工作流程。但是,我想与其他人分享它,并认为将其作为 GitHub Action 发布到市场将是最用户友好的选择。我创建了一个包含action.yml
其他必需文件的新仓库。但是,即使在编辑了工作流程之后,我也无法通过这个Set up job
阶段。我想知道我需要进行哪些调整才能获得action.yml
与原始工作流程相同的有效性,因为我还没有任何经验。原始工作流程、action.yml 和错误消息可以在下面找到。原始工作流程按预期工作,但在由uses
关键字执行时无法正常工作。
原始工作流程(按预期工作):
name: Yaml autosync
description: Auto-sync changes to a template YAML localisation file to all other YAML files in the same directory.
branding:
icon: file-text
color: blue
inputs:
lang_path:
description: 'Path to the folder that contains all lang files'
default: .
required: false
default_file:
description: 'The name of the YAML file that contains all default options. These values are used to fill in any missing info in the other files.'
default: 'default.yml'
required: false
github_token:
description: 'The secret GitHub Token so this action has push access. Make sure to use GitHub secrets and do not push any private info!'
required: true
on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
LANG_PATH: ${INPUT_LANG_PATH}
DEFAULTS: ${INPUT_DEFAULT_FILE}
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Clone YAML-localisation-sync
run: git clone some_repo
- name: Building the project
run: |
cd YAML-localisation-sync
mvn package
- name: Moving JAR file
run: cp YAML-localisation-sync/target/YamlLocalisation.jar ${LANG_PATH}
- name: Running JAR file
run: |
cd ${LANG_PATH}
java -jar YamlLocalisation.jar ${DEFAULTS}
- name: Repo cleanup
run: |
rm -rf YAML-localisation-sync
cd ${LANG_PATH}
rm YamlLocalisation.jar
- name: Commit changes
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "YAML sync bot"
git add .
git commit -m "Sync YAML localisation files"
git fetch
continue-on-error: true
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${INPUT_GITHUB_TOKEN}
force: true
Action.yml(上面的工作流程,更新为在市场上作为 GitHub Action 工作)
name: Yaml autosync
description: Auto-sync changes to a template YAML localisation file to all other YAML files in the same directory.
branding:
icon: file-text
color: blue
inputs:
lang_path:
description: 'Path to the folder that contains all lang files'
default: .
required: false
default_file:
description: 'The name of the YAML file that contains all default options. These values are used to fill in any missing info in the other files.'
default: 'default.yml'
required: false
github_token:
description: 'The secret GitHub Token so this action has push access. Make sure to use GitHub secrets and do not push any private info!'
required: true
on: [push]
runs:
using: "composite"
env:
LANG_PATH: ${INPUT_LANG_PATH}
DEFAULTS: ${INPUT_DEFAULT_FILE}
steps:
- run: git clone https://github.com/MyProfile/YAML-localisation-sync.git
shell: bash
- run: |
cd YAML-localisation-sync
mvn package
shell: bash
- run: cp YAML-localisation-sync/target/YamlLocalisation.jar ${LANG_PATH}
shell: bash
- run: |
cd ${LANG_PATH}
java -jar YamlLocalisation.jar ${DEFAULTS}
shell: bash
- run: |
rm -rf YAML-localisation-sync
cd ${LANG_PATH}
rm YamlLocalisation.jar
shell: bash
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "YAML sync bot"
git add .
git commit -m "Sync YAML localisation files"
git fetch
shell: bash
continue-on-error: true
有错误的工作流(在用于测试已发布 GitHub 操作的存储库中)
name: GitHub Actions
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Yaml autosync
uses: MyProfile/MyRepo@15
with:
github_token: ${secrets.GITHUB_TOKEN}
lang_path: foldertest/
default_file: en.yml
错误信息
Current runner version: '2.277.1'
Operating System
Virtual Environment
GITHUB_TOKEN Permissions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v2'
Download action repository 'actions/setup-java@v1'
Download action repository 'MyProfile/MyAction@15'
Error: MyProfile/MyAction/15/action.yml (Line: 28, Col: 3): Unexpected value 'steps'
Error: MyProfile/MyAction/15/action.yml (Line: 28, Col: 3): Unexpected value 'steps'
Error: System.ArgumentNullException: Value cannot be null. (Parameter 'You are using a composite action but there are no steps provided in MyProfile/MyAction/15/action.yml.')
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 MyProfile/MyAction/15/action.yml
解决方案
推荐阅读
- ios - 如何在 FSCalender swift 中禁用用户交互?
- google-cloud-platform - 将 --source-machine-image 与“gcloud beta compute instances create”CLI 命令一起使用时,不会创建额外的永久性磁盘
- python - 如何用与其他列具有相同值的列的值填充列中的 nan 值
- javascript - 如何测试 2 个画布图像在 JS 画布上是否小于 x 个像素?
- image - 如何在 woocommerce 循环中修改图像输出?
- javascript - 在 Y 轴上旋转图像并显示不同的 div
- javascript - 如何使用ajax将对象作为数据发送?
- asp.net - 用 Typescript 替换 ASP.NET 中的 aspx 页面中引用的 MicrosoftAjax.js
- node.js - 预启动脚本中的 Dotenv 环境变量
- android - 如何在 Flutter 中根据屏幕大小调整测试大小?