英文:
Can I automatically create a label on a github repo?
问题
我们的组织将代码存储在 GitHub 上,我们希望我们团队创建的新存储库遵循特定的工作方式(例如,每个存储库都应该有一个默认的工作流程在.github/workflows
中,一个基本的.gitignore
,在.github
中的linter配置文件等等)。因此,我们建立了存储库模板,人们可以使用名为 cookiecutter 的工具来实例化。这个工具运行得非常好。不过请注意,cookiecutter 只自动创建内容,它不会实际创建 Git 存储库(也就是它不会运行 git init
),也不会在 GitHub 上创建任何内容。因此,使用我们的模板的工作流程如下:
cookiecutter --output-dir new-repo-name https://github.com/our-org/our-template-repo
cd new-repo-name
git init
gh repo create new-repo-name --private --source=. --remote=upstream
git add .
git push
希望你能明白。
然后,我们想要能够跟踪从我们的模板创建的所有 GitHub 存储库。我们认为一个不错的方法是确保每个这些存储库都有特定的标签。
因此,我希望能够自动在这些新创建的存储库上创建标签。有人知道如何做到吗?(我希望通过将某个特定文件放入.github
目录中来实现这一点,但很遗憾似乎没有这样的方法。)
英文:
Our organisation stores code on github and there are certain ways-of-working that we want new repos created by our team to adhere to (e.g. there is a default set of workflows at .github/workflows
that each repo should have, a basic .gitignore
, linter config files in .github
, etc..). Hence we have built repo templates that people can instantiate using a tool called cookiecutter. Its working really well. Note though that cookiecutter only automates the creation of content, it doesn't actually create the git repo (i.e. it doesn't run git init
) and it doesn't create anything on github. Hence, the workflow for someone to use one of our templates is:
cookiecutter --output-dir new-repo-name https://github.com/our-org/our-template-repo
cd new-repo-name
git init
gh repo create new-repo-name --private --source=. --remote=upstream
git add .
git push
Hopefully you get the idea.
We then had an idea that we would like to be able to track all the github repos that get created from our templates. We thought a nice way of doing that would be to ensure that each of those repos had a certain label on them.
Hence I'd like to be able to automatically create labels on such newly created repos. Does anyone know a way of doing that? (I was hoping there was perhaps a way of achieving it by putting a certain file into the .github
directory, but alas it seems there is no such thing.)
答案1
得分: 1
唯一浮现在我脑海中的标签是经典的GitHub标签,用于问题和拉取请求。您还可以使用GitHub CLI创建它们。在您的情况下,您可以像这样添加 gh label create template --description "使用模板xyz创建" --color 348AA7
到您的脚本中。如果这对您有帮助,请告诉我。
英文:
The only labels that come to my mind are the classic GitHub Labels for issues and pull requests. You can also create them with the GitHub CLI. In your case you could add something like gh label create template --description "Created with template xyz" --color 348AA7
to your script. Let me know if this was helpful.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论