Forking actions/checkout@v2 at organization level to be used repo's github actions

Viewed 960

Problem:

Inherently, github actions has no information about the code within the repo it's being run in. To rid that problem, there is the actions/checkout workflow that is the defacto start of most workflows.

Our enterprise account got locked down to only local actions only: enter image description here

Because of this, we are not able to use the actions/checkout@v2 at the start of our workflow, thus rendering our Github Actions useless.

Proposed Solution

Fork the actions/checkout repo as a submodule of a repo and use that reference in my code like so:

steps:
  - uses: <enterprise_name>/<repo_name>/checkout@main

When running this action as a test, I get this error message:

Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under
'/home/runner/work/_actions/<enterprise_name>/<repo_name>/main/checkout'. 
Did you forget to run actions/checkout before running your local action?

So my question:

Is there a way to run a forked or local version of actions/checkout? The above example is telling me, I can't run a local version of actions/checkout because I have clone the repo which is ironic error.

1 Answers

You need to push the actions/checkout repo into an internal or public repo on your enterprise. Then update your workflow to reference organization/repo@2 instead.

After forking the actions/checkout repo to my jessehouwing-actions this would result in the following update of the YAML:

steps:
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  - uses: actions/checkout@v3

Would become:

steps:
  # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  - uses: jessehouwing-actions/checkout@v3

Don't use submodules.

Related