Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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