最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to access files of GitHub Action repo when using that action in another repo? - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question edited Sep 19, 2024 at 5:12 reduckted 2,5283 gold badges31 silver badges37 bronze badges asked Jun 24, 2022 at 21:58 nooneninenoonenine 1193 silver badges13 bronze badges 3
  • Please show how you're using the action. Also, what is the visibility of the repository containing the action? Private? Internal? Public? – rethab Commented Jun 25, 2022 at 15:19
  • Both the repositories are Internal and in same organization. I'm using the action with 1. uses (org_name/repo_name@main) and 2. with - inputs, that I defined in action.yml. – noonenine Commented Jun 27, 2022 at 14:29
  • Please update your question to contain a minimal reproducer. – rethab Commented Jun 27, 2022 at 15:46
Add a ment  | 

1 Answer 1

Reset to default 9

You can access an action repository files in a posite 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 posite 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 posite 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 posite 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.

发布评论

评论列表(0)

  1. 暂无评论