0

I have a github actions config file that I want to place by default in my github repository. How can I create a new file .workflow/config.yml when i create new repository on github?

Since the Gihub template doesn't seem to be essential, I'm thinking of using github actions to automatically create a config file after a new repository is created. But i couldn't find event that new repository.

mbt
  • 29
  • 9
  • Not sure what you mean by "template doesn't seem to be essential," because a template repo would definitely be a simple solution. But you could also use a [.github repo](https://stackoverflow.com/questions/60507097/is-there-an-overview-of-what-can-go-into-a-github-dot-github-directory#:~:text=On%20Github%2C%20folder%20.,%2C%20CODE_OF_CONDUCT.md%20etc) (note the leading dot). – Zac Anger May 18 '23 at 02:14
  • @ZacAnger thank you for reply. I think that the meaning of it is that you need to select it yourself when you create a new repository with the current template, but what I want to do is automatically set the configuration file. – mbt May 18 '23 at 04:26

1 Answers1

0

.github (as a repo name in your user/org) can be used to provide default files for other repos. Some details on the contents of .github are in this discussion, and the general docs are over here.

With starter workflows, all the work is already done in your .github repo, and you just need to enable and configure (if needed) the actions before they can be run (see the docs).

With reusable workflows, you will still have to specify that you're pointing to an upstream workflow (with uses). This could be done in a template, and would still reduce config drift, but might be an annoyance.

An alternate solution might be to write your own CLI tool that generates the appropriate files, or if you use the gh cli tool, to use the --template flag (you could even wrap it in a shell function, like gh_init() { gh repo create "$1" --template="my_user_name/my_template_repo"; };).

Zac Anger
  • 6,983
  • 2
  • 15
  • 42