Skip to content

Instantly share code, notes, and snippets.

@TylerLeonhardt
Last active June 28, 2020 20:37
Show Gist options
  • Save TylerLeonhardt/92a110303212edcb7ad140bb5f2c1414 to your computer and use it in GitHub Desktop.
Save TylerLeonhardt/92a110303212edcb7ad140bb5f2c1414 to your computer and use it in GitHub Desktop.
Add JustinGrote/Super-Duper-Linter to all GitHub repos! - depends on Microsoft/PowerShellForGitHub
#Requires -Modules PowerShellForGitHub
# Change this to you:
$owner = 'TylerLeonhardt'
# This will ignore forks
Get-GitHubRepository -OwnerName $owner -Sort Pushed | Where-Object fork -ne $true | ForEach-Object {
# Clone the repo and move into it
$item = New-Item -ItemType Directory -Path "Temp:/$(New-Guid)/$($_.name)"
git clone $_.ssh_url $item.FullName
$item | Push-Location | Out-Null
try {
# Create the directory, and add the linter yml file.
New-Item -ItemType Directory -Force -Path './.github/workflows' | Out-Null
$yaml = './.github/workflows/linter.yml'
(Invoke-RestMethod 'https://raw.githubusercontent.com/TylerLeonhardt/macOSdefaultsCompleter/master/.github/workflows/linter.yml').Trim() > $yaml
# Do all git operations to push the change
$branch = 'add-super-duper-linter'
$message = 'Add Super Duper Linter'
git checkout -b $branch
git add $yaml
git commit -m $message
git push origin $branch
# Create the Pull Request on GitHub
$params = @{
Uri = $_.html_url
Title = $mesage
Body = "Adding [Super-Duper-Linter](https://github.com/JustinGrote/Super-Duper-Linter) to this repo."
Head = $branch
Base = $_.default_branch
}
New-GitHubPullRequest @params | Select-Object state,html_url
} finally {
# Clean up
Pop-Location | Out-Null
$item | Remove-Item -Force -Recurse | Out-Null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment