How to use a custom github action from another repository in my organization?
Asked Answered
S

3

9

I'm following the examples of a docker Github action to create my own action. I would like to keep the action in a private repository in my organization, and then re-use it from another repositories under the same organization.

The documentation states that "When an action is in a private repository, the action can only be used in workflows in the same repository" but, to my understanding, it doesn't cover how such actions behave in organization context - only in standalone repo context. Do I have to make it public and on the marketplace, just to be able to re-use it in my own private organization?

Does anyone have any experience setting up such an action?

Sprinkle answered 17/9, 2020 at 15:34 Comment(0)
N
1

Github has introduced a new repository sharing option, called internal. With internal repositories it is possible to share actions across repositories. Please note that only some types of organizational accounts are entitled to this visibility option.

https://dev.to/n3wt0n/finally-custom-github-actions-in-internal-repos-4l91

Nazarius answered 13/9, 2022 at 7:16 Comment(0)
C
4

Expanding on @MujtabaMehdi's answer: the copying can actually be done as part of the action itself:

      - 
        uses: actions/checkout@v3
        with:
          repository: your-org/your-action
          path: your-action
      - 
        uses: ./your-action

(This pollutes the current folder. I originally tried to checkout the action to /tmp/your-action, but uses only takes paths that start with ./. You could still put it in the parent directory with ./../your-action, but checkout also doesn't want to write anything there -.-.)

Compensate answered 12/1, 2023 at 7:31 Comment(0)
E
1

I have recently published a custom action to GitHub marketplace, You have two options:

  • Publish your custom GitHub action to the marketplace and then use it with any repository wherever you like however this will require you to make your code public
  • Second option is to copy all the contents of the GitHub action you created (entrypoint.sh, dockerfile and action.yml) to the repository where you want to use it and simply use it like this: uses: ./

Do let me know if this solves your problem, thanks

Elisabethelisabethville answered 4/12, 2020 at 14:47 Comment(0)
N
1

Github has introduced a new repository sharing option, called internal. With internal repositories it is possible to share actions across repositories. Please note that only some types of organizational accounts are entitled to this visibility option.

https://dev.to/n3wt0n/finally-custom-github-actions-in-internal-repos-4l91

Nazarius answered 13/9, 2022 at 7:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.