Override repository env var #25649
-
I want to run an action on another repository. I have made a personal access token and overidden the repo name env var, however the repo name doesn’t seem to override correctly. Heres a simple example of this: Is there a way to override this env var? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Few points may be helpful to you to understand:
For example, two repositories, Repo-A and Repo-B , and there is a workflow in Repo-A , this workflow can’t run in Repo-B. If you want some steps in the workflow can run based on the source code in Repo-B , you can add a step in the workflow to checkout the source code from Repo-B into the specified directory under the workspace of the workflow, then execute the related steps the directory of Repo-B. |
Beta Was this translation helpful? Give feedback.
-
@brightranthanks for the detailed response. Perhaps if I share more about my use case it will help. When a workflow runs in RepoA I want one of the steps to act on RepoB (and RepoC, RepoD, etc). Looking at the action it uses the GITHUB_REPOSITORY env var in the API calls it makes, so I need to be able to override this. I was hoping to use a matrix to store the list of repos to act on. From a permissions point of view I’ve created a personal access token which has permission to modify all repos that I need, and I can provide that in the config as a secret. |
Beta Was this translation helpful? Give feedback.
-
Whether that action you are using in your workflow has an input parameter that allows users to specify which repository the API is executed for? Please check it. If the environment variable " GITHUB_REPOSITORY" has been set as the default input and the fixed input in the action, you indeed can’t specify other repositories. As a workaround, maybe you can try to copy/fork the repository of the action into your own organization. Then add an input parameter to allow users to specify which repository the API is executed for, and also replace " GITHUB_REPOSITORY" with this input parameter in the related scripts executed in the action. Then you can use this custom action in your workflow. About creating actions, you can reference the docs: https://help.github.com/en/actions/building-actions |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. It’s a shame it’s not possible to override this, I guess forking is my only option as you suggest. |
Beta Was this translation helpful? Give feedback.
-
Facing the same situation. It would’ve been great to be able to override a default environment variable. Fork it is then. |
Beta Was this translation helpful? Give feedback.
@jacobtomlinson ,
Whether that action you are using in your workflow has an input parameter that allows users to specify which repository the API is executed for? Please check it.
If the environment variable " GITHUB_REPOSITORY" has been set as the default input and the fixed input in the action, you indeed can’t specify other repositories.
As a workaround, maybe you can try to copy/fork the repository of the action into your own organization. Then add an input parameter to allow users to specify which repository the API is executed for, and also replace " GITHUB_REPOSITORY" with this input parameter in the related scripts executed in the action. Then you can use this custom action in yo…