Last active
January 31, 2020 09:47
-
-
Save felixfbecker/5d34177ba05e43e078df7c2b8be1817e to your computer and use it in GitHub Desktop.
Automation for sending out coding exercises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Modules PSGitHub, PSGSuite | |
function New-CodingExercise { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string] $CandidateUsername, | |
[Parameter(Mandatory)] | |
[string] $CandidateName, | |
[Parameter(Mandatory)] | |
[string] $CandidateEmail, | |
[Parameter(Mandatory)] | |
[string] $Interview | |
) | |
process { | |
$repo = Copy-GitHubTemplateRepository ` | |
-Owner sourcegraph ` | |
-Name "coding-exercise-$CandidateName" ` | |
-TemplateOwner sourcegraph ` | |
-TemplateName "interview-$Interview" ` | |
-Private | |
$repo | Add-GitHubRepositoryCollaborator -Username $CandidateUsername | Out-Null | |
$body = " | |
Hi $CandidateName! | |
Here's the link to your coding exercise: $($repo.HtmlUrl) | |
- Nick | |
" | |
Send-GmailMessage -Subject "Coding Exercise" -Body $body -To $CandidateEmail | |
} | |
} | |
function Close-CodingExercise { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string] $CandidateUsername, | |
[Parameter(Mandatory)] | |
[string] $CandidateName, | |
[Parameter(Mandatory)] | |
[string] $CandidateEmail, | |
[Parameter(Mandatory)], | |
[string[]] $Reviewers | |
) | |
process { | |
$repo = @{ | |
Owner = 'sourcegraph' | |
RepositoryName = "coding-exercise-$CandidateName" | |
} | |
Remove-GitHubRepositoryCollaborator @repo -Username $CandidateUsername | Out-Null | |
New-GitHubIssue @repo ` | |
-Title "Review coding exercise" ` | |
-Body "Please submit your feedback to Google Hire." ` | |
-Assignees $Reviewers | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment