derberg / manage-files-in-multiple-repositories

GitHub Action that introduces support for global workflows. Global workflows are the one you update in just one repo and they are automatically updated in other repositories.
MIT License
51 stars 18 forks source link

Copy to specific repo while using push trigger event #49

Open miran-hadz opened 1 year ago

miran-hadz commented 1 year ago

Hi,

I love the action that you've created, really useful! I want to check only one functionality possibility. I see from docs that the only way to specify which repo to copy to is when using on workflow_dispatch. Is there any chance that you could add the same functionality by checking an env variable of the same name?

I might be wrong in understanding how the API gets the list of repos, but since I am using a PAT token, and in a big organization, I assume it would list all of those repos. I would be probably fired if I messed with all of the other repos πŸ˜„ (I don't have write access on most of them but do have on 15ish repos).

So in summary:

  1. Is there a way to provide support for repo_name as an env or similar (to be used with push trigger event)?
  2. Alternatively, could we provide a list of repositories where we need to copy the files (instead of the other way around, mentioning which repos to ignore)?

Side question; are regex patterns supported under patterns_to_ignore, patterns_to_remove (neew PR you've created) and similar..? If so, can you show me an example (say I want to remove mod.main.bicep from all subfolders in a repo)

derberg commented 1 year ago

Hey man, glad you like it, v2 was just released and I renamed repo as it no longer only copies files, it can also remove files.

are regex patterns supported under patterns_to_ignore, patterns_to_remove (neew PR you've created) and similar..?

I'm using JS includes function there, so kinda regex. So when you specify ./github/workflows then all files from that dir will be ignored

Is there a way to provide support for repo_name as an env or similar (to be used with push trigger event)

not sure if we can figure out from PAT what repos you have access to. Isn't topics_to_include useful for you, so you can add topic to repo and then update only repos that have that topic?

derberg commented 1 year ago

Also, if you like this project, please leave a star ⭐ as maybe once it gets too popular, then GitHub will support it natively πŸ˜„

miran-hadz commented 1 year ago

I'm using JS includes function there, so kinda regex. So when you specify ./github/workflows then all files from that dir will be ignored

I was more referring to patterns in file names, e.g. ignoring file names "mod.main.bicep" in all folders

not sure if we can figure out from PAT what repos you have access to. Isn't topics_to_include useful for you, so you can add topic to repo and then update only repos that have that topic?

How do you figure out the repos then? Do you use all inside organization or? I guess I could use topics but then the danger is someone might use the same topic in a different repo and get access to files they shouldn't otherwise have. Is there a reason why specificing a list of repos is not supported through code?

derberg commented 1 year ago

I was more referring to patterns in file names, e.g. ignoring file names "mod.main.bicep" in all folders

oh, damn I just noticed you are interested with removal even though it was not yet released πŸ˜ƒ tbh your case is supported as https://github.com/derberg/manage-files-in-multiple-repositories/blob/main/lib/utils.js#L110 is probably doing /my/path/mod.main.bicep.includes('mod.main.bicep'). You need to run a test but basically the idea is that you provide patterns, so mod.main.bicep is a pattern that can match to multiple different files as I'm comparing to file paths.

How do you figure out the repos then? Do you use all inside organization or? I guess I could use topics but then the danger is someone might use the same topic in a different repo and get access to files they shouldn't otherwise have. Is there a reason why specificing a list of repos is not supported through code?

just to clarify, so you mean you want it to run on multiple repos that are not under one org but can be in different orgs and private profiles?

miran-hadz commented 1 year ago

I want to copy to multiple repos which I choose under one organization.

derberg commented 1 year ago

ok, so basically requirement is: copy/remove from just few repos in the same org.

I always recommend topics_to_include or push to all and filter out exceptions using repos_to_ignore

I never added repos_to_include as noone ever had a use case to manually specify repo where files should be pushed to. More flexible is topics_to_include as whoever wants some workflow, do not have to open a PR.

related discussion: https://github.com/derberg/manage-files-in-multiple-repositories/issues/8

miran-hadz commented 1 year ago

The only difference is, I am not copying workflows but rather providing code for customers (for IaC related projects). And I basically want to automatically update a template-repository that customers can always have the low-code, latest version. When there is a push to main on repo A, I copy over some subset of files to repo template-repository (so I don't need to do it manually all the time). I guess I could use topics it's just that in that case, the scope is not in my control. We have 7k repos in organization so I'm worried someone might use the same topic and they get the code all of a sudden.

derberg commented 1 year ago

We have 7k repos in organization

oh πŸ˜…

repos_to_include is a pretty valid use case then πŸ˜ƒ