在另一个仓库中使用该操作时,如何访问GitHub Action Repo的文件?

发布于 2025-02-10 09:27:34 字数 604 浏览 1 评论 0原文

我创建了一个JavaScript自动化,在该脚本中,我创建了几个YML文件,并且使用FS和JS-YAML库导入它们。我已经在Repo A中托管了此代码。

我想将仓库A转换为GitHub操作。我遵循了 documentation>创建JavaScript操作。我已经使用了 vercel/ncc 用Github建议的所有库来创建一个文件。

但是,当我在repo b中使用此操作时,我会遇到一个错误,说YML文件在上述路径上不可用。

GitHub Workflow在执行过程中是否下载动作的存储库?如果是,如何将这些YML文件传递到脚本中?

如果没有,将这些文件传递到脚本中的选项是什么?

I have created a JavaScript automation and in that script I have created couple of YML files and I'm importing them using fs and js-yaml libraries. I have hosted this code in repo A.

I want to convert my repo A into a GitHub action. I have followed the documentation from GitHub to create JavaScript action. I have used the vercel/ncc to create one file with all my libraries as suggested by GitHub.

But when I use this action in repo B, I get an error saying the yml files are not available at the mentioned path.

Does GitHub workflow download the action's repo during execution? if yes, how can I pass these yml files into the script?

If not, what are the options to pass these files into script?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一张白纸 2025-02-17 09:27:34

您可以通过使用action.yml文件访问复合操作中的操作存储库文件多变的。

动作所在的路径。此属性仅在复合动作中支持。您可以使用此路径来访问与操作同一存储库中的文件。
BlockQuote

来源: github文档

例如,如果您需要执行python脚本script.py.py位于操作存储库中的 Run在复合操作中的步骤,您必须使用类似的东西:

run: python "${{ github.action_path }}/script.py"
shell: bash

注:我建议告知 shell 避免问题,因为可以在任何OS跑步者上使用复合动作。

我创建了一个小动作作为参考作为参考,如果使用此概念,则使用此概念。您想看看。

You can access an action repository files in a composite action from the action.yml file by using the ${{ github.action_path }} context variable.

The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action.
Blockquote

Source: Github Documentation about Context

For example, if you need to execute a python script script.py located in the action repository from a run step in a composite action, you would have to use something like this:

run: python "${{ github.action_path }}/script.py"
shell: bash

Note: I suggest to inform the shell to avoid problem as composite actions can be used on any OS runner.

I've created a small action as reference which uses this concept if you want to have a look.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文