Override repository env var

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?

@jacobtomlinson ,

Few points may be helpful to you to understand:

  1. We generally use the " env" key or the workflow command " ::set-env name={name}::{value}" to set/update the custome environment variables. The custom environment variables set via these two ways will be added into the env context.

  2. The " GITHUB_REPOSITORY" is a default environment variable set by GitHub. When you try using the " env" key or the " set-env" command to change the value of a default environment variable, GitHub will prevent the value from being changed on the system, but this environment variable will be added into the  env context with the new value.

  3. According to above two points, in the workflow, if you want to access the new value of an environment variable which is set/updated via the " env" key or the " set-env" command, the general method is using the expression syntax " env.<env name>" to access the environment variable in the  env context. For the updated default environment variable, this is the only method to access its new value, you can’t use the expression syntax that access the system environment variable to get its new value.

  4. Currently, GitHub does not support a repository to run a workflow located in another repository.

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.

@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.

@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 your workflow.

About creating actions, you can reference the docs: https://help.github.com/en/actions/building-actions

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.