AndreasAugustin / actions-template-sync

:octocat: Github action for syncing other repositories (templates) with current repository. Any git provider like GitHub (enterprise), GitLab, Gittea,.. are supported for the source repository

Home Page:https://andreasaugustin.github.io/actions-template-sync/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[QUESTION] Can this be used in source repository?

hrishikeshrt opened this issue · comments

I am sorry if this is a silly question. Is it possible to setup this action in the source template repository so that anyone who clones this will get the changes as well?

Hi! Thank you for your contribution!'Happy coding! 🚀

Hi @hrishikeshrt thank you for the question.
Unfortunately I do not fully understand the use case.
Could you please clarify what you want to achieve? Maybe with an example?
Thanks 👍

I have a template repository.
Say there are two users A and B who want to use it as a template. Now, I make some changes to the template. I wish that A and B don't have to do anything to get those changes. So, something like, I set up the workflow in template itself (which does some check so that it doesn't run for myself), and whenever someone uses the template they get the workflow, so that they get periodic updates.

I hope I've made it a bit clearer. Please let me know if you'd like me to elaborate further.

thanks for the clarification.
I can think about 2 theoretical ways how this could be achieved

  • the source repository is able to push the changes to the users repositories -> that means that the source repository need to somehow have permissions to the users repositories to push the changes. This solution is not capable of such a feature. The management of the permissions wouldn't be super easy.
  • the users repositories have a cron job setup to pull for changes. This is possible when you are in the context of a git server. E.q. your user is a repository in GitHub. Here you can setup a cron job using the available docker container or the current github action.

When we are in context of GitHub, you can also add the action into the source repository as a yaml file (do not forget to disable the action within the source repository, in most cases it does not give a value when you sync the source repo with it self) -> each newly created repository using your template repository will have the sync action setup per default.

When a user is now a human and want to auto sync the template, it would be possible to use the available docker images and run them in a cron job. (or you use the shell scripts in a linux daemon). But you need to disable the pr part, this is possible with the is-dry_run flag. But you need to add a hook to do the push part. This would also be possible if you use the docker image within other git servers (GitLab,...)

I hope that I got the question right and that my answers are somehow clear :)

Source repository being able to push is not a good option IMO. Doesn't make sense for a repository that is meant to be used by arbitrary users on GitHub.

When we are in context of GitHub, you can also add the action into the source repository as a yaml file (do not forget to > disable the action within the source repository, in most cases it does not give a value when you sync the source repo
with it self) -> each newly created repository using your template repository will have the sync action setup per default.

This is sort of what I am looking for, that users, when they use a template, get the action as well so they don't have to set anything up themselves. I am not clear on how docker is playing a role. I guess I will need to read up more.

Thank you for your suggestions.

If you are just in a user (human) context, then maybe another option is a nicer way:
git hooks https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

The idea is that you add a hook for the users so that for some git actions the source repo is pulled with changes.
But I am honestly not super sure if I understand your use cases perfectly.

There are tools outside, which help you to share the hooks within the repo like npm husky https://github.com/typicode/husky

If you want to use this action then it is also possible to add e.q. a docker-compose.yml into the repository and a git hook triggering the container with docker-compose. As mentioned already there are docker images available for the action

Hi @hrishikeshrt . do you have further questions?

Thank you for checking with me. I haven't been able to explore all the options due to some other commitments.

However, this can be closed for now.
Thanks for your help.