JavaRush /Java Blog /Random EN /Optimizing work with your projects on GitHub: getting acq...

Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository

Published in the Random EN group
Hello everyone, JavaRush community! Optimizing work with your projects on GitHub: introduction to Github Template Repository - 1 Today we’ll talk about open source and what it takes to create a high-quality project IN ADDITION to the code that is written. It is important to write a useful product. But no less important is the correct design of the repository (project repository on GitHub). This will help in implementing another key point - product promotion. Even if the project is super cool, but if it is poorly designed, is not described at least in the README (you can read about what a README is here ), the license is not indicated, etc., etc., there will be no success. It's just that no one will notice him. And if someone notices, they won’t know how to interact with him. There are a lot of things that need to be filled out over and over again, and it’s not easy for the programmer to copy and paste each time, and just for this, this summer, GitHub released the Template Repository feature that helps with this. So to speak, to automate the process of creating new projects. Today we will understand what a Repository is and what a Template Repository is. We will describe what should be in the project besides the code, what things you need to focus on. Let's create a Template Repository from scratch and add everything necessary from my point of view. And finally, we will use Template Repository when creating a new repository. But first, let's understand the terms.

Repository is something like a folder for a project in GitHub. The repository contains all the files that belong to the project. It stores the entire history of project changes, which is very important.

Using the Issues tab, you can create defects, improvements, and questions for the project.

Using Projects , you can create Kanban boards to track the status of issues, their implementation and planning.

Template repository is a template based on which you can create new repositories. A template that contains common code for all repositories.

Theory: what should be in the general repository of any project Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository - 2Every open source project on GitHub should have a well-described Community Profile , which contains the following elements.

1. Issue template

Here you need to describe the rules for creating an issue in the repository: what they should be called, what the label will be, who will be assigned to it. When creating a new Issue, the following options will be offered:
  • Bug report - creating an issue to describe a defect in the project;
  • Feature request - proposal of a new idea for a project;
  • Improvement request - proposal for improvement on the project;
  • Custom issue template - if other options do not work, you can use an empty template.
An example of what this looks like can be seen here .

2. License

The license under which the project is written. It is necessary so that those who will use the project know what is guaranteed and what is not. For example, the Apache License 2.0 says the following: Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository - 3

3.README

This is a description of the project, its calling card. Everything that needs to be said about the project should be here. Of course, it will need to be described each time, taking into account the specifics of the project, but the headings will be the same. For example:
  • Overview - a brief description of the project;
  • Usage - how to use the project;
  • Building - how to launch a project, what is needed for this;
  • Troubleshooting - this describes what problems you may encounter and how to solve them;
  • Release Notes - description of changes depending on the version;
  • Authors - don’t forget about your loved ones;
  • Contributing - a description of how you can participate in the development of the project;
  • Code of Conduct - description of the rules of participation;
  • RELEASE_NOTES - a file in which all changes for new versions are recorded. It’s a good practice to put this in a separate document and store a link in the README;
  • CONTRIBUTING is a file that describes how you can contribute to the development of this project. Made as a separate file for the Contributing header in the README;
  • CODE_OF_CONDUCT - a file that describes the rules for participating in the development of the project;
  • Pull Request template - a template for those who will create a pull-request.
All these things are used from project to project, regardless of the programming language or its specifics.

Practice: creating your own template

As they say, let's move from words to action. Now, using an example, I will show you how to create your own template.
  1. The first thing you need is an account on GitHub / register there .

  2. Create a new repository: to do this, click + in the upper right corner

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 4
  3. When creating, fill in:

    • Repository name - in my case repository-template;
    • Description — brief description of the project;
    • We leave Public, although you can select Private;
    • Check the README initialization box:

      Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository - 5
    • Select the license under which the project will be:

      Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository - 6

      Since in my case the template is general, gitignore is not needed: it will be added for a specific project and programming language.

      Therefore, click Create Repository , thereby completing the creation process. The system will automatically take us to the newly created repository.

  4. Filling out the Community Profile : in the created repository, go to the Insights tab and select Community :

    Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository - 7

    As you can see, all that remains is to fill out the Code of Conduce, Contributing, Issue Template, Pull Request template.

    Using the Code of Conduct example, we will show how to add them to a project.

    Click add , the system prompts you to select Contributor Covenant or Citizen Code of Conduct :

    Optimizing work with your projects on GitHub: getting acquainted with Github Template Repository - 8

    I select the first one and click Review and Submit .

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 9

    Next, you can edit this file and commit it.

    At the bottom, select the Commit directly to the master branch option and click Commit new file :

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 10

    As a result, if we go back to the Community Profile , we will find that Code of Conduct is marked as added:

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 11

    Contributing and Issue Template are added in a similar way, so I won’t show this. Do it yourself ;)

  5. Add Pull Request template .

    But let's talk about this separately.

    I don’t know why GitHub hasn’t added the same convenient option for setting up the Pull-Request template, so you’ll have to study the documentation and add it manually.

    To do this, click Create new file in the root of the repository :

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 12

    The file name should be: .github/pull_request_template.md .

    We add what we need to the template and click Commit new file , as we did above. I wasn't going to reinvent the wheel and found an example that seemed quite usable to me.

    This way the entire Community Profile will be filled in:

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 13
  6. Add a Template Repository marker .

    To do this, go to the Settings option in the repository and check the box where it says Template Repository:

    Optimizing work with your projects on GitHub: introduction to Github Template Repository - 14

    And that’s it, the template for creating new projects is ready. Thus, we will save a lot of time in the future when we need to create new projects. This will also help you not to miss important details, since it often happens that you forget to add something, for example a license or a clear template for an issue.

How to use Template Repository

There are two options for use:

  1. When a template is owned directly by you: When creating a new repository, you will be given the option to create from a template from the list of templates you own:

    We optimize work with our projects on GitHub: getting acquainted with Github Template Repository - 15
  2. When the template is foreign: there are no special problems here either. Go to that template and click the Use this template button . Here I will use the animation from the official doc:

Let's sum it up

In this article we looked at:
  • what is GitHub repository;
  • what is Template repository;
  • what should be in the Template repository;
  • how to create a Template Repository;
  • how to use Template Repository.
Of course, based on this template, you can already create more specific ones. For example, I created more templates with maven or gradle build systems already configured. Further more: you can create a Spring Boot Repository Template based on the last two. To group all the templates, I created a template-repository organization on GitHub with all the templates. Subscribe to my GitHub account

useful links

Optimizing work with your projects on GitHub: introduction to Github Template Repository - 17

More of my articles

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION