Last active
May 5, 2020 15:53
-
-
Save IlyaFinkelshteyn/aea8408cc7c7c836431dab8f898d09a1 to your computer and use it in GitHub Desktop.
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
$token = '<API_TOKEN>' # account-level API token | |
$headers = @{ | |
"Authorization" = "Bearer $token" | |
"Content-type" = "application/json" | |
} | |
# create new project | |
$body = @{ | |
repositoryProvider="gitHub" | |
repositoryName="<githib_user_name>/<github_repo_name>" | |
} | |
$body = $body | ConvertTo-Json | |
#use 'https://ci.appveyor.com/api/account/<appveyor_account_name>/projects' endpount is using v2 'all accounts' API token | |
$newProject = Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects' -Headers $headers -Body $body -Method POST | |
# read existing project config | |
# note: by default <appveyor_account_name> is the same as <githib_user_name> and <appveyor_project_name> is the same as <github_repo_name> | |
$s = Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects/<appveyor_account_name>/<appveyor_project_name>/settings' -Headers $headers -Method Get | |
# update config with new project data | |
$s.settings.projectId = $newProject.projectId | |
$s.settings.slug = ($s.settings.slug + "-new") | |
# optionally update project name | |
$s.settings.name = ($newProject.name + "-new") | |
#update new project | |
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects' -Headers $headers -Body ($s.settings | ConvertTo-Json -Depth 10) -Method Put |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment