Using repository templates

Learn how to create repository templates and how to use them to create new repositories

This public content is an excerpt from Flutter staff GitHub docs. It is published as a reference to show how GitHub is used for inner source at Flutter.

This guide provides instructions on how to create new repositories using templates with the Codebase Governor (CBG). Follow these steps to efficiently manage your repositories within a capability.

Using templates in Codebase Governor provides several benefits, including:

  • Standardization: You can ensure that all your repositories have the same configuration and settings.
  • Time-saving: Creating new repositories from a template saves you time and reduces errors.
  • Consistency: Your repositories will be consistent across your organization, making it easier to manage and maintain them.

Template Creation

To create a new template, add or use an existing repository configuration file within the appropriate capability folder. If the repository does not already exist in Flutter-Global, the Codebase Governor will automatically create it and apply all necessary configurations.

To create a new template, follow these steps:

  1. Navigate to the org-config repository main page.
  2. Open the codebases folder.
  3. Open your capability folder or create a new one.
  4. Click the Add file > Create new file button.
  5. If the repository doesn’t exist: enter your repository name in the Name your file... field. The file name must follow the <NAME_OF_REPOSITORY>.yml pattern. For example, for a repository named my-template, the filename would be my-template.yml.
  6. If the repository already exists: navigate to the repository configuration file and click the Edit this file button.
  7. Add the is-template key in the repository configuration properties in the file contents textarea.

       is-template: true
    
  8. Click on the Commit changes... button.
  9. Add a Commit message.
  10. Click on Propose changes to open a Pull Request.

Once the pull request is approved and merged, CBG will create the template and apply any changes defined in the configuration.

After designating the repository as a template, add the desired content and configurations that will be used in future repositories created from this template.

Using Templates

To use an existing template for creating a new repository, add a using-template property to your repository configuration file.

For example:

using-template: <repository_name>

This will create a new repository with the same configuration as the my-template template.

To use a template, follow these steps:

  1. Navigate to the org-config repository main page.
  2. Open the codebases folder.
  3. Open your capability folder or create a new one.
  4. Click the Add file > Create new file button.
  5. Enter your repository name in the Name your file... field. The file name must follow the <NAME_OF_REPOSITORY>.yml pattern.
  6. Add the using-template property to the file contents textarea, specifying the template you want to use.

     using-template: my-template
    
  7. Click on the Commit changes... button.
  8. Add a Commit message.
  9. Click on Propose changes to open a Pull Request.

Once the pull request is approved and merged, CBG will create the new repository using the template configuration.

Next Steps

Refer to the documentation for more details.