Skip to content

Instantly share code, notes, and snippets.

@rufer7
Created November 14, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rufer7/55168303927d45604d8e to your computer and use it in GitHub Desktop.
Save rufer7/55168303927d45604d8e to your computer and use it in GitHub Desktop.
Automated GitHub repositorycreation for d-fens GmbH
# requires -Modules biz.dfch.PS.System.Utilities
$token = '';
$username = '';
$repositoryName = '';
$repositoryDescription = '';
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$token)));
Invoke-RestMethod -Uri https://api.github.com/orgs/dfensgmbh/repos -Credential $base64AuthInfo;
# DFTODO - Get available templates from GET /gitignore/templates
# DFTODO - Get available licenses from GET /licenses
# Create repo
$body = @{name=$repositoryName;description=$repositoryDescription;private=$false;has_issues=$true;has_wiki=$true;has_downloads=$true;auto_init=$true;gitignore_template="VisualStudio";license_template="apache-2.0"} | ConvertTo-Json -Compress;
Invoke-RestMethod -Uri https://api.github.com/orgs/dfensgmbh/repos -Headers @{"Authorization"="Basic $base64AuthInfo"} -Method Post -Body $body;
# DFTODO - Add license badge to README ([![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/dfensgmbh/biz.dfch.CS.OData.OAuth/blob/master/LICENSE))
# Do this with git
# Create labels
$body = @{name="feature";color="fbca04"} | ConvertTo-Json -Compress;
Invoke-RestMethod -Uri https://api.github.com/repos/dfensgmbh/biz.dfch.CS.CIMI.Client/labels -Headers @{"Authorization"="Basic $base64AuthInfo"} -Method Post -Body $body;
$body = @{name="onhold";color="fad8c7"} | ConvertTo-Json -Compress;
Invoke-RestMethod -Uri https://api.github.com/repos/dfensgmbh/biz.dfch.CS.CIMI.Client/labels -Headers @{"Authorization"="Basic $base64AuthInfo"} -Method Post -Body $body;
$body = @{name="task";color="0052cc"} | ConvertTo-Json -Compress;
Invoke-RestMethod -Uri https://api.github.com/repos/dfensgmbh/biz.dfch.CS.CIMI.Client/labels -Headers @{"Authorization"="Basic $base64AuthInfo"} -Method Post -Body $body;
# DFTODO - Create NOTICE (read sample file and replace escaped text sections with real text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment