How to reuse a whole workflow?

Hello everybody,

I think I had a fundamental misunderstandig of Actions. So let me ask something first:

A job in a workflow consists of one more more steps. Steps can use other Actions. But an Action is something else than a workflow, as an Action executes only a single command.

Is this correct?

If my current understanding is correct, how can I share an entire workflow with multiple steps with multiple repositories?

Best,

Oliver

3 Likes

Hey! If you are a little fuzzy on what a GitHub action is and how it’s used, check out this link: https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions#about-github-actions

From the docs: “You can write individual tasks, called actions, and combine them to create a custom workflow”

If I am understanding your question right, you want to share a workflow between repos? I am not sure you have have a shared set of workflows between repos. The workflows and actions operate on a repo by repo basis. 

If you want to copy a workflow from one repo too another, you will need to copy the “.github” folder from one repo to the next. This will move over all of your workflows and subsequent actions. 

3 Likes

From the docs: “You can write individual tasks, called actions, and combine them to create a custom workflow”

Yes, I missed this sentence. :confused: But this is that I was afraid of. It would be nice to be able to share workflows.

I will see that fits best my use case. Copying or using a Git submodule.

6 Likes

Why is this thread marked as solved? It’s not solved by any means, reusing a workflow doesn’t seem to be possible in any way – I have copy & pasted my configuration to about 15 projects and each time I want to make a change, I currently have to do it in 15 repositories … :frowning_face:

11 Likes

Why is this thread marked as solved? It’s not solved by any means, reusing a workflow doesn’t seem to be possible in any way – I have copy & pasted my configuration to about 15 projects and each time I want to make a change, I currently have to do it in 15 repositories …

Totally agree, sharing worklows between repos would be a great feature

10 Likes

I’m wondering if anything is on the roadmap for this, it is a long requested feature. We would love to get rid of Jenkins as it has its flaws, but as we rely on Jenkins shared libraries we cannot migrate to GitHub Actions until a similar feature is introduced. We simply need a way to define a pipeline/workflow for building a certain project type, which can be used by many repositories, and without having to change all these repositories when we need to fix something in the workflow.

1 Like

Struggling with the same issue. We have over 50 repo’s and I have some very simple workflows to just label, approve and merge PR’s which need to be applied to all. These unfortunately cannot be put into a single workflow since they act on different events.

I have been trying using a submodule but this does not seem to work. The .github folder now is a submodule, but the workflows in it are not executed anymore.

2 Likes

Isn’t it possible to have these workflows in a submodule, include that at say /submodules/workflows/ and the have symlinks / hardlinks at /.github/workflow.yml -> pointing at /submodules/workflows/workflow.yml
this way it should be possible to “select” which workflows to really use in the sepcific repo and even use different branches on different repos.

The lack of built in support for this problem led me to create a CLI tool that wraps existing templating engines (ytt or Jsonnet) to manage workflows more effectively. In case it’s of interest: https://github.com/jbrunton/gflows

It looks like it is intended to be an enterprise feature: https://github.com/github/roadmap/issues/98
Which is a shame, because small teams that also have multiple projects with the same workflow would still have to resort to all kinds of workarounds.

1 Like

That issue also has the “cloud” label which I thought meant that the feature would also be available on github.com as well as in GitHub Enterprise?

@agarthetiger I am under the impression that this all means that it is available under the enterprise subscription on github.com, not just the on-premise one. We currently have a Team subscription at work with 20 developers, so that would be a big price increase if we would want to re-use workflows efficiently in the future…