Marc Rufer bio photo

Marc Rufer

Software engineer
@d-fens GmbH

Twitter LinkedIn Github Stackoverflow
RSS Feed

GitHub Repository creation with PowerShell

Marc Rufer 25 Nov 2015 PowerShell GitHub automation

After a longer period of time without blogging I have something interesting for you. In the last few weeks I had to create several GitHub repositories for my daily work. To simplify the process I automated the creation with PowerShell.

I created and initialized the repositories manually until I recognized that this is a perfect task to automate. First I studied the documentation of the GitHub API v3, which is very well documented! Fortunately for me the GitHub API supports all the functions I needed.

The automation contains the following steps:

  • Create a new repository
  • Initialize with one of the licenses provided by the license endpoint
  • Initialize with one of the gitignore files provided by the gitignore endpoint
  • Add a NOTICE file based on a predefined template to the repository
  • Add the license shield to the readme if Apache License 2.0 was selected as license
  • Add labels feature, onhold and task to the repository

The PowerShell script that performs all the steps described above. The script, the corresponding configuration file and the README and NOTICE template can be found in the GitHub repository PS.GitHub.RepoCreator. Feel free to use it and to contribute or create issues for desired use cases.

How to use

  1. Create an access token for command-line use (For details see here)
  2. Check out the sources from the PS.GitHub.RepoCreator repository
  3. Navigate to the src folder
  4. Config.xml: Fill in your GitHub username and the access token generated in step 1
  5. NOTICE_Template: Adjust the content according your wishes (IMPORTANT: The placeholders REPONAME and REPODESCRIPTION always have to occur at least once in the file)
  6. README_Template: Adjust the content according your wishes (IMPORTANT: The placeholders REPONAME, LICENSEBADGE and REPODESCRIPTION always have to occur at least once in the file)
  7. Now you’re ready to execute the script which will do the following
  8. Creation of a new repository with the selected license and the selected gitignore file
  9. In case you selected Apache 2.0 as license, it will add a license badge to the README file
  10. Creation of a NOTICE file based on the NOTICE_Template
  11. Creation of 3 new issue labels: feature, onhold, task

Sample invocation

PS C:\PS.GitHub.RepoCreator\src> .\New-GitHubRepo.ps1 -RepoName 'NAME' -RepoDescription 'DESCRIPTION'
comments powered by Disqus

Posts

HOWTO Access Azure File Share in PowerShell Script executed by a Scheduled Task BUG "Task Scheduler service is not available" Error, if specifying Network Connection Condition HOWTO Sync OneDrive on Server even if Windows User not logged in HOWTO Access Microsoft Access Database with PowerShell Get NetworkCredential from PSCredential splits Username into Username and Domain HOWTO Create LocalDB File (.mdf) manually in Visual Studio 2015 HOWTO Set Cookie Header on DefaultRequestHeaders of HttpClient HOWTO Set up PowerShell Remote Session Configuration HOWTO Analyze PowerShell Scripts with PSScriptAnalyzer HOWTO Sign PDF with SuisseID NoBrainer PUT/PATCH/MERGE with OData Service Client Apply Commit from one Repository to another GitHub Repository creation with PowerShell HOWTO Sign PowerShell Script with SuisseID Swissunihockey game schedule PDF generator HOWTO Maven Release on JetBrains TeamCity Limitations when running Activiti in H2 Embedded Mode HOWTO Pylint Integration in IntelliJ 14 HOWTO Install Windows 10 IoT Core on Raspberry PI 2 from a VM First steps with Dropwizard Allman code style for IntelliJ First steps with Flyway IntelliJ - Setup custom inspection profiles Configuration properties meta-data support in IntelliJ AMQP Integration with spring integration OCA Java SE 7 Programmer I Certification Guide Swissunihockey key matcher Swisscom SMS-API-Client Some hints concerning logging with Log4j IFTTT A brilliant service Run deltacloud on a VirtualBox-VM Project specific maven settings in IntelliJ AngularJS Javascript for beginners Liferay in Action