Adding GH Valet CLI support (#1)
* Update readme.md * Update readme.md * Update valet-audit-lab.md * Delete valet * Delete valet-update * Update devcontainer.json * Update valet-audit-lab.md * Update valet-dry-run-lab.md * Update valet-migrate-custom-lab.md * Update valet-migrate-lab.md * Update valet-migrate-lab.md * Update valet-audit-lab.md * Update valet-dry-run-lab.md * Update valet-migrate-custom-lab.md * Update .env.local * Update valet-migrate-lab.md * Update valet-audit-lab.md * Update valet-dry-run-lab.md * Update valet-migrate-lab.md * Update valet-migrate-custom-lab.md * Update devcontainer.json * Update devcontainer.json * Create setenvars.sh * Update readme.md * Update readme.md * Update valet-audit-lab.md * Update valet-dry-run-lab.md * Update valet-migrate-lab.md * Update valet-migrate-custom-lab.md * Update and rename setenvars.sh to setupcodespace.sh * Update devcontainer.json * Update azure_devops/readme.md Co-authored-by: Ethan Dennis <[email protected]> * Update readme.md * Update azure_devops/readme.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-audit-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-audit-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-migrate-custom-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis <[email protected]> * Update readme.md * Update readme.md * Update devcontainer.json * Update devcontainer.json * Update readme.md * Update devcontainer.json * Update readme.md * Update valetbsazdo.yml * Create .gitignore * Update readme.md * Update readme.md * Update azDevOps.ps1 * Delete updateEnvs.ps1 * Update devcontainer.json * Update readme.md * Update azure_devops/valet-audit-lab.md Co-authored-by: David Hathaway <[email protected]> * Update azure_devops/valet-audit-lab.md Co-authored-by: David Hathaway <[email protected]> * Update valet-audit-lab.md * Update valet-dry-run-lab.md * Update azure_devops/valet-dry-run-lab.md Co-authored-by: David Hathaway <[email protected]> * Update azure_devops/valet-migrate-lab.md Co-authored-by: David Hathaway <[email protected]> * Update valet-dry-run-lab.md * Update readme.md * Update readme.md * Update setupcodespace.sh * Rename .env.local to .env.local.template * Update .gitignore Co-authored-by: Ethan Dennis <[email protected]> Co-authored-by: David Hathaway <[email protected]>
This commit is contained in:
co-authored by
Ethan Dennis
David Hathaway
parent
54108c642b
commit
03753a327f
@@ -46,11 +46,31 @@ $projectToCreate = @{
|
||||
}
|
||||
}
|
||||
|
||||
$projectResponse = Invoke-RestMethod -Method 'Post' -Uri $createtUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($projectToCreate|ConvertTo-Json) -ContentType "application/json"
|
||||
$projectResponse | ConvertTo-Json
|
||||
try{
|
||||
$projectResponse = Invoke-RestMethod -Method 'Post' -Uri $createtUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($projectToCreate|ConvertTo-Json) -ContentType "application/json"
|
||||
$projectResponse | ConvertTo-Json
|
||||
|
||||
Start-Sleep -s 5
|
||||
Write-Host "Yes! Project $project was created!"
|
||||
Start-Sleep -s 5
|
||||
Write-Host "Yes! Project $project was created!"
|
||||
|
||||
} Catch {
|
||||
Write-Host " "
|
||||
Write-Host "##########################################################################"
|
||||
Write-Host "ERROR during project creation: $project"
|
||||
Write-Host "The API call was: $createtUrlToUse"
|
||||
Write-Host " "
|
||||
|
||||
if($_.ErrorDetails.Message) {
|
||||
Write-Host "See error message below:"
|
||||
Write-Host $_.ErrorDetails.Message
|
||||
} else {
|
||||
Write-Host $_
|
||||
Write-Host "It is likely that the AZURE_DEVOPS_ACCESS_TOKEN is not set correctly in the worflow OR does not have sufficent permissions"
|
||||
}
|
||||
Write-Host " "
|
||||
Write-Host "##########################################################################"
|
||||
throw "Exiting. The Project $project was NOT created in Azure DevOps"
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# IMPORT THE REPO
|
||||
@@ -82,15 +102,15 @@ $addTextFile = @{
|
||||
$daFullName = $codeFile.FullName
|
||||
$codeBody = (Get-Content "$daFullName" -Raw)
|
||||
#Write-Host "codeBody: $codeBody"
|
||||
Write-Host "folder: $folder"
|
||||
#Write-Host "folder: $folder"
|
||||
$relath = $daFullName | Resolve-Path -Relative
|
||||
Write-Host "relath: $relath"
|
||||
#Write-Host "relath: $relath"
|
||||
$replaceSlash = $folder.Replace("/", "\")
|
||||
$repoPath = $relath.Substring($relath.lastIndexOf($replaceSlash) + $replaceSlash.Length)
|
||||
$wholeRepoPath = Join-Path -Path $itemPath -ChildPath $repoPath
|
||||
$wholeRepoPath = $wholeRepoPath.Replace("\", "/")
|
||||
Write-Host "wholeRepoPath: $wholeRepoPath"
|
||||
Write-Host "repoPath: $repoPath"
|
||||
#Write-Host "wholeRepoPath: $wholeRepoPath"
|
||||
#Write-Host "repoPath: $repoPath"
|
||||
@{
|
||||
"changeType"= "add"
|
||||
"item"= @{
|
||||
@@ -108,13 +128,28 @@ $addTextFile = @{
|
||||
)
|
||||
}
|
||||
|
||||
try{
|
||||
$repoUrlToUse = [string]::Format("https://dev.azure.com/{0}/{2}/_apis/git/repositories/{1}/pushes?api-version=7.1-preview.2", $orgToUse, $repoName, $project)
|
||||
$pushResponse = Invoke-RestMethod -Method 'Post' -Uri $repoUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($addTextFile|ConvertTo-Json -Depth 5) -ContentType "application/json"
|
||||
$repoIds = $pushResponse.repository.id
|
||||
Write-Host "Yes! Repo Was was created! The repoId is $repoIds"
|
||||
} Catch {
|
||||
Write-Host " "
|
||||
Write-Host "##########################################################################"
|
||||
Write-Host "ERROR during Repo creation:"
|
||||
Write-Host "The API call was: $repoUrlToUse"
|
||||
Write-Host " "
|
||||
|
||||
$repoUrlToUse = [string]::Format("https://dev.azure.com/{0}/{2}/_apis/git/repositories/{1}/pushes?api-version=7.1-preview.2", $orgToUse, $repoName, $project)
|
||||
$pushResponse = Invoke-RestMethod -Method 'Post' -Uri $repoUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($addTextFile|ConvertTo-Json -Depth 5) -ContentType "application/json"
|
||||
$repoIds = $pushResponse.repository.id
|
||||
Write-Host "Yes! Repo Was was created!"
|
||||
|
||||
Write-Host "Yes! Repo was imported into $repoIds"
|
||||
if($_.ErrorDetails.Message) {
|
||||
Write-Host "See error message below:"
|
||||
Write-Host $_.ErrorDetails.Message
|
||||
} else {
|
||||
Write-Host $_
|
||||
}
|
||||
Write-Host " "
|
||||
Write-Host "##########################################################################"
|
||||
throw "Exiting. The Repo was NOT created. It is likely the Project was created in Azure DevOps."
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
@@ -141,10 +176,26 @@ foreach ($f in $files)
|
||||
}
|
||||
}
|
||||
}
|
||||
#$pipelineCreateBody | ConvertTo-Json
|
||||
|
||||
try{
|
||||
$repoResponse = Invoke-RestMethod -Method 'Post' -Uri $plUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($pipelineCreateBody|ConvertTo-Json) -ContentType "application/json"
|
||||
} Catch {
|
||||
Write-Host " "
|
||||
Write-Host "##########################################################################"
|
||||
Write-Host "ERROR during Pipeline creation:"
|
||||
Write-Host "The API call was: $plUrlToUse"
|
||||
Write-Host " "
|
||||
|
||||
$repoResponse = Invoke-RestMethod -Method 'Post' -Uri $plUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($pipelineCreateBody|ConvertTo-Json) -ContentType "application/json"
|
||||
$repoResponse | ConvertTo-Json
|
||||
if($_.ErrorDetails.Message) {
|
||||
Write-Host "See error message below:"
|
||||
Write-Host $_.ErrorDetails.Message
|
||||
} else {
|
||||
Write-Host $_
|
||||
}
|
||||
Write-Host " "
|
||||
Write-Host "The Pipeline $nameOfPl was NOT created."
|
||||
Write-Host "##########################################################################"
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
@@ -161,7 +212,24 @@ foreach ($f in $files)
|
||||
|
||||
$pclassicreateBody = (Get-Content ./$pipelinesRoot/classic/$fileName).Replace("REPOTOREPLACE", "$repoName")
|
||||
|
||||
$repo2Response = Invoke-RestMethod -Method 'Post' -Uri $classicUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($pclassicreateBody) -ContentType "application/json"
|
||||
$repo2Response | ConvertTo-Json
|
||||
try{
|
||||
Invoke-RestMethod -Method 'Post' -Uri $classicUrlToUse -Headers @{"Authorization"="Basic $BasicCreds"} -Body ($pclassicreateBody) -ContentType "application/json"
|
||||
} Catch {
|
||||
Write-Host " "
|
||||
Write-Host "##########################################################################"
|
||||
Write-Host "ERROR during Pipeline creation:"
|
||||
Write-Host "The API call was: $classicUrlToUse"
|
||||
Write-Host " "
|
||||
|
||||
if($_.ErrorDetails.Message) {
|
||||
Write-Host "See error message below:"
|
||||
Write-Host $_.ErrorDetails.Message
|
||||
} else {
|
||||
Write-Host $_
|
||||
}
|
||||
Write-Host " "
|
||||
Write-Host "The Pipeline $nameOfPl was NOT created."
|
||||
Write-Host "##########################################################################"
|
||||
}
|
||||
}
|
||||
Write-Host "End Valet Bootstrap"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
param (
|
||||
[String]$proj = "ValetBootstrapper",
|
||||
[String]$org = "microsoft-bootcamp",
|
||||
[String]$ghPAT = "dkalmintest",
|
||||
[String]$azdoPAT = "[email protected]"
|
||||
)
|
||||
|
||||
[String]$azdoProject = "AZURE_DEVOPS_PROJECT="
|
||||
[String]$azdoOrg = "AZURE_DEVOPS_ORGANIZATION="
|
||||
[String]$azdoInstance = "AZURE_DEVOPS_INSTANCE_URL="
|
||||
[String]$ghAccess = "GITHUB_ACCESS_TOKEN="
|
||||
[String]$azdoAccess = "AZURE_DEVOPS_ACCESS_TOKEN="
|
||||
|
||||
$updateEnvs = (Get-Content ./valet/.env.local)
|
||||
|
||||
$updateEnvs = $updateEnvs.Replace("$azdoProject", "AZURE_DEVOPS_PROJECT=$proj")
|
||||
$updateEnvs = $updateEnvs.Replace("$azdoOrg", "AZURE_DEVOPS_ORGANIZATION=$org")
|
||||
$updateEnvs = $updateEnvs.Replace("$azdoInstance", "AZURE_DEVOPS_INSTANCE_URL=https://dev.azure.com/$org")
|
||||
$updateEnvs = $updateEnvs.Replace("$ghAccess", "GITHUB_ACCESS_TOKEN=$ghPAT")
|
||||
$updateEnvs = $updateEnvs.Replace("$azdoAccess", "AZURE_DEVOPS_ACCESS_TOKEN=$azdoPAT")
|
||||
Set-Content -Path ./valet/.env.local -Value $updateEnvs
|
||||
+73
-54
@@ -4,6 +4,8 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you
|
||||
|
||||
- [Use this Repo as a template](#repo-template)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Codespace secrets](#codespace-secrets)
|
||||
- [Action secrets](#action-secrets)
|
||||
- [Azure DevOps project creation](#azure-devops-project-creation)
|
||||
- [Use Valet with a codespace](#use-valet-with-a-codespace)
|
||||
- [Labs for Azure DevOps](#labs-for-azure-devops)
|
||||
@@ -14,8 +16,11 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you
|
||||
|
||||
## Prerequisites
|
||||
1. Azure DevOps organization. Please identify or create an Azure DevOps organization to use: [Click to create an Azure DevOps Org](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/create-organization?toc=%2Fazure%2Fdevops%2Fget-started%2Ftoc.json&bc=%2Fazure%2Fdevops%2Fget-started%2Fbreadcrumb%2Ftoc.json&view=azure-devops)
|
||||
- Note and store the organization name for later.
|
||||
2. Create an Azure DevOps personal access token with the following scopes:
|
||||
- Note and store the Azure DevOp sorganization name for later.
|
||||
- Note and store the user name you use for your Azure DevOps Organization. It will be an email address.
|
||||
2. Azure DevOps Project. The default project name for this lab is `ValetBootstrap` There is an Action workflow that will create and populate the Azure DevOps project. No need to create it yourself. Note: The project has to be unique in the Azure DevOps organization. If you already have a project name `ValetBootstrap` please pick a differnt unique project name.
|
||||
- Note and store the Azure DevOps project name for later.
|
||||
3. Create an Azure DevOps personal access token with the following scopes:
|
||||
- To do so, navigate to Sign in to your organization `https://dev.azure.com/{yourorganization}`.
|
||||
- From your home page, open `user settings`, and then select `Personal access tokens`.
|
||||
- Select `+ New Token`
|
||||
@@ -23,67 +28,67 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you
|
||||
- Select the following scopes:
|
||||
- Agents Pool: `Read`
|
||||
- Build: `Read & Execute`
|
||||
- Code: `Full, Execute`
|
||||
- Code: `Read & Write`
|
||||
- Project and Team: `Read, Write, & Manage`
|
||||
- Release: `Read`
|
||||
- Service Connections: `Read`
|
||||
- Variable Groups: `Read`
|
||||
- Click `Create`
|
||||
- Copy the PAT somewhere safe and temporary.
|
||||
3. Create a GitHub personal access token.
|
||||
4. Create a GitHub personal access token.
|
||||
- To do so, navigate to your GitHub `Settings` - click your profile photo and then click `Settings`.
|
||||
- Go to `Developer Settings`
|
||||
- Go to `Personal Access Tokens` -> `Legacy tokens`
|
||||
- Click `Generate new token` -> `Legacy tokens`. If required, provide your password.
|
||||
- Go to `Personal Access Tokens` -> `Legacy tokens (if present)`
|
||||
- Click `Generate new token` -> `Legacy tokens (if present)`. If required, provide your password.
|
||||
- Select at least these scopes: `read packages` and `workflow`. Optionally, provide a text in the **Note** field and change the expiration.
|
||||
- Click `Generate token`
|
||||
- Copy the PAT somewhere safe and temporary.
|
||||
4. Add GitHub personal access token to the CODESPACES **Secrets** tab.
|
||||
- Navigate to the `Settings` tab in your repo
|
||||
- Find `Secrets` and click the down arrow
|
||||
- Click `Codespaces`
|
||||
- Click `New Codespaces Secret` to create a new secret.
|
||||
- Name the secret `VALET_PASSWORD`
|
||||
- Paste in the GitHub PAT generated previously
|
||||
- Click `Add Secret`
|
||||
|
||||
## Codespace secrets
|
||||
Please add the following Codespace secrets.
|
||||
|
||||
- `VALET_GHCR_PASSWORD`: Add `VALET_GHCR_PASSWORD` as the `Name` and the GitHub personal access token created above as the value.
|
||||
- `AZURE_DEVOPS_ACCESS_TOKEN`: Add `AZURE_DEVOPS_ACCESS_TOKEN` as the `Name` and the Azure DevOps personal access token created above as the value.
|
||||
- `AZURE_DEVOPS_ORGANIZATION`: Add `AZURE_DEVOPS_ORGANIZATION` as the `Name` and the Azure DevOps organization noted above as the value.
|
||||
- `AZURE_DEVOPS_PROJECT`: Add `AZURE_DEVOPS_PROJECT` as the `Name` and the Azure DevOps project noted above as the value.
|
||||
|
||||
Steps to create the Codespace secrets. Complete for secret noted above:
|
||||
|
||||
- Navigate to the `Settings` tab in this repo
|
||||
- Find `Secrets` and click the down arrow
|
||||
- Click `Codespaces`
|
||||
- Click `New Codespaces Secret` to create a new secret
|
||||
- Name the secret as noted above
|
||||
- Paste in the value noted above
|
||||
- Click `Add Secret`
|
||||
|
||||
## Action secrets
|
||||
Please add the following Action secrets.
|
||||
|
||||
- `AZURE_DEVOPS_ACCESS_TOKEN`: Add `AZURE_DEVOPS_ACCESS_TOKEN` as the `Name` and the Azure DevOps personal access token created above as the value.
|
||||
|
||||
Steps to create the Codespace secret. Complete for secret noted above:
|
||||
|
||||
- Navigate to the `Settings` tab in this repo
|
||||
- Find `Secrets` and click the down arrow
|
||||
- Click `Actions`
|
||||
- Click `New Repository Secret` to create a new secret
|
||||
- Name the secret as noted above
|
||||
- Paste in the vale noted above
|
||||
- Click `Add Secret`
|
||||
|
||||
## Azure DevOps project creation
|
||||
|
||||
1. Add your Azure DevOps personal access token to the Actions **Secrets** tab.
|
||||
- Navigate to the `Settings` tab in this repo
|
||||
- Find `Secrets` and click the down arrow
|
||||
- Click `Actions`
|
||||
- Click `New Repository Secret` to create a new secret.
|
||||
- Name the secret `AZDOPAT`
|
||||
- Paste in the Azure DevOps PAT generated previously
|
||||
- Click `Add Secret`
|
||||
|
||||
2. Add Azure DevOps personal access token, project, and org to the CODESPACES **Secrets** tab.
|
||||
- Navigate to the `Settings` tab in your repo
|
||||
- Find `Secrets` and click the down arrow
|
||||
- Click `Codespaces`
|
||||
- Click `New Codespaces Secret` to create a new secret.
|
||||
- Name the secret `AZDO_TOKEN`
|
||||
- Paste in the Azure DevOps PAT generated previously
|
||||
- Click `Add Secret`
|
||||
- Click `New Codespaces Secret` to create another secret.
|
||||
- Name the secret `AZDO_PROJECT`
|
||||
- Type in the Azure DevOps project name. This should be `ValetBootstrap`
|
||||
- Click `Add Secret`
|
||||
- Click `New Codespaces Secret` to create a new secret.
|
||||
- Name the secret `AZDO_ORG`
|
||||
- Type in the Azure DevOps organization name
|
||||
- Click `Add Secret`
|
||||
|
||||
3. Run the Actions workflow
|
||||
- CLick the `Actions` tab
|
||||
- Select the `Valet Bootstrap for Azure DevOps` action
|
||||
- Click `Run Workflow`
|
||||
- Input the Azure DevOps Organization name identified above
|
||||
- Input the Azure DevOps user name of the user that created the Azure DevOps PAT above. This will be an email address
|
||||
- Accept the default Azure DevOps project name or change it to one of your preference
|
||||
- Click `Run Workflow`
|
||||
- Verify the workflow completed successfully
|
||||
Run the Actions workflow:
|
||||
- CLick the `Actions` tab
|
||||
- Select the `Valet Bootstrap for Azure DevOps` action
|
||||
- Click `Run Workflow`
|
||||
- Input the Azure DevOps Organization name identified above
|
||||
- Input the Azure DevOps user name of the user that created the Azure DevOps PAT above. This will be an email address
|
||||
- Accept the default Azure DevOps project name or change it to one of your preference
|
||||
- NOTE: The default project name is `ValetBootstrap`. This must be unique in your Azure DevOps Organization. If not, please choose a unique name.
|
||||
- Click `Run Workflow`
|
||||
- Verify the workflow completed successfully. If the workflow did not run successfully you will see a detailed error message.
|
||||
|
||||
### Example ###
|
||||

|
||||
@@ -96,11 +101,14 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you
|
||||
- Click the `Codespaces` tab
|
||||
- Click `New Codespace`
|
||||
- Wait a couple minutes, then verify that the codespace starts up. Once it is fully booted up, the termininal should be present.
|
||||
2. Run Valet
|
||||
- Verify you are in the Visual Studio Code terminal
|
||||
- Change to the Valet directory by typing `cd scripts`
|
||||
- Run the valet command by typing `valet`. Verify that Valet details all commands.
|
||||
- Start using Valet
|
||||
2. Verify Valet CLI is installed and working. More information on the [GitHub Valet CLI extension](https://github.com/github/gh-valet)
|
||||
- Verify Valet CLI is installed and working
|
||||
- Run `gh valet version` in the Visual Studio Code terminal and verify the output looks like the below image.
|
||||
- If `gh valet version` did not produce a similar image please follow these instructions [Troubleshoot GH Valet extension](#troubleshoot-gh-valet-extension)
|
||||
- Start using Valet by following along with the [Labs for Azure DevOps](#labs-for-azure-devops)
|
||||
|
||||
### Example ###
|
||||

|
||||
|
||||
## Labs for Azure DevOps
|
||||
Perform the following labs to test-drive Valet
|
||||
@@ -109,3 +117,14 @@ Perform the following labs to test-drive Valet
|
||||
- [Migrate an Azure DevOps pipeline to GitHub Actions](valet-migrate-lab.md)
|
||||
- [Migrate an Azure DevOps pipeline to GitHub Actions with a custom transformer](valet-migrate-custom-lab.md)
|
||||
- [Forecast: Valet forecast lab](valet-forecast-lab.md)
|
||||
|
||||
## Troubleshoot GH Valet extension
|
||||
Manually Install the GitHub CLI Valet extension. More information on the [GitHub Valet CLI extension](https://github.com/github/gh-valet)
|
||||
- Verify you are in the Visual Studio Code terminal
|
||||
- Run this command to install the GitHub Valet extension
|
||||
- `gh extension install github/gh-valet`
|
||||
- Verify the result of the install is: `✓ Installed extension github/gh-valet`
|
||||
- If you get a similiar error to the following, click the link to authorize the token
|
||||

|
||||
- Restart Codespace after clicking the link
|
||||
- Verify Valet CLI is installed and working
|
||||
|
||||
@@ -1,44 +1,62 @@
|
||||
# Audit Azure DevOps pipelines using the Valet audit command
|
||||
In this lab, you will use Valet to audit Azure DevOps pipelines in an Azure DevOps project.
|
||||
In this lab, you will use Valet to `audit` an Azure DevOps organization. The `audit` command can be used to scan a CI server and output a summary of the current pipelines. This summary can then be used to plan the timeline and effort required to migrate to GitHub Actions.
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Perform an audit](#perform-an-audit)
|
||||
- [View audit output](#view-audit-output)
|
||||
- [Review the pipelines](#review-the-pipelines)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment
|
||||
2. Create or start a codespace in this repository (if not started)
|
||||
3. Verify or add the following values to the `valet/.env.local` file. All values were created [here](/labs/azure_devops#readme)
|
||||
```
|
||||
GITHUB_ACCESS_TOKEN=<GithHub PAT generated>
|
||||
GITHUB_INSTANCE_URL=https://github.com/
|
||||
|
||||
AZURE_DEVOPS_PROJECT=<Project identified>
|
||||
AZURE_DEVOPS_ORGANIZATION=<Org identified>
|
||||
AZURE_DEVOPS_INSTANCE_URL=<DevOps instance>
|
||||
AZURE_DEVOPS_ACCESS_TOKEN=<Token Generated>
|
||||
```
|
||||
### Example ###
|
||||
|
||||

|
||||
|
||||
## Perform an audit
|
||||
You will use the codespace preconfigured in this repository to perform the audit.
|
||||
|
||||
1. Navigate to the codespace Visual Studio Code terminal
|
||||
2. Verify you are in the scripts directory
|
||||
3. Now, from the `./scripts` folder in your repository, run Valet to verify your Azure DevOps configuration:
|
||||
2. Verify you are in the `valet` directory
|
||||
3. Now, from the `valet` folder in your repository, run Valet to verify your Azure DevOps configuration:
|
||||
|
||||
```
|
||||
cd scripts
|
||||
valet audit azure-devops --output-dir .
|
||||
gh valet audit azure-devops --output-dir .
|
||||
```
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
4. Valet displays green log files to indicate a successful audit
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
## View audit output
|
||||
The audit summary, logs, Azure DevOps yml, and GitHub yml should all be located in the scripts folder.
|
||||
The audit summary, logs, Azure DevOps yml, and GitHub yml should all be located in the `valet` folder.
|
||||
|
||||
1. Under the `scripts` folder find the `audit_summary.md`
|
||||
2. Right-click the `auditsummary.md` file and select `Open Preview`
|
||||
3. The file contains the audit summary details about what can and can't be migrated to GitHub Actions.
|
||||
1. Under the `valet` folder find the `audit_summary.md`
|
||||
2. Right-click the `audit_summary.md` file and select `Open Preview`
|
||||
3. The file contains details about your current pipelines and what can be migrated 100% automatically vs. what will need some manual intervention or aren't supported by GitHub Actions.
|
||||
4. Review the file.
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
## Review the pipelines
|
||||
The `audit` command grabs the yml, classic, and release pipelines from Azure DevOps and converts them to GitHub Actions.
|
||||
|
||||
### Example
|
||||
View the source yml and the proposed GitHub yml
|
||||

|
||||

|
||||
|
||||
|
||||
@@ -1,49 +1,62 @@
|
||||
# Dry run the migration of an Azure DevOps pipeline to GitHub Actions
|
||||
In this lab, you will use the `valet dry-run` command on one Azure DevOps pipeline.
|
||||
In this lab, you will use the `valet dry-run` command to convert an Azure DevOps pipeline to it's equivalent GitHub Actions workflow and write the workflow to your local filesystem.
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Identify the Azure DevOps pipeline ID to use](#identify-the-azure-devops-pipeline-id-to-use)
|
||||
- [Perform a dry run](#perform-a-dry-run)
|
||||
- [View dry-run output](#view-dry-run-output)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment
|
||||
2. Create or start a codespace in this repository (if not started)
|
||||
3. You have completed the [Valet audit lab](valet-audit-lab.md).
|
||||
4. Verify or add the following values to the `valet/.env.local` file. All values were created [here](/labs/azure_devops#readme)
|
||||
```
|
||||
GITHUB_ACCESS_TOKEN=<GithHub PAT generated>
|
||||
GITHUB_INSTANCE_URL=https://github.com/
|
||||
|
||||
AZURE_DEVOPS_PROJECT=<Project identified>
|
||||
AZURE_DEVOPS_ORGANIZATION=<Org identified>
|
||||
AZURE_DEVOPS_INSTANCE_URL=<DevOps instance>
|
||||
AZURE_DEVOPS_ACCESS_TOKEN=<Token Generated>
|
||||
```
|
||||
### Example ###
|
||||
|
||||

|
||||
|
||||
## Identify the Azure DevOps pipeline ID to use
|
||||
You will need a pipeline ID to perform the dry run
|
||||
1. Go to the `scripts/ValetBootstrap/pipelines` folder
|
||||
2. Open the `scripts/ValetBootstrap/pipelines/valet-mapper-example.config.json` file
|
||||
3. Look for the `web - href` link
|
||||
1. Go to the `valet/ValetBootstrap/pipelines` folder
|
||||
2. Open the `valet/ValetBootstrap/pipelines/valet-pipeline1.json` file
|
||||
3. Look for the `$.web.href` link
|
||||
4. At the end of the link is the pipeline ID. Copy or note the ID.
|
||||
|
||||
### Example
|
||||

|
||||
|
||||

|
||||
|
||||
## Perform a dry run
|
||||
You will use the codespace preconfigured in this repository to perform the dry run.
|
||||
|
||||
1. Navigate to the codespace Visual Studio Code terminal
|
||||
2. Verify you are in the scripts directory
|
||||
3. Copy the following command and replace:
|
||||
- `GITHUB-ORG` with the name of your organization.
|
||||
- `GITHUB-REPO` with the name of your repository.
|
||||
- `PIPELINE-ID` with your pipeline ID.
|
||||
2. Verify you are in the `valet` directory
|
||||
|
||||
```
|
||||
cd scripts
|
||||
valet dry-run azure-devops pipeline --target-url https://github.com/GITHUB-ORG/GITHUB-REPO --pipeline-id PIPELINE-ID --output-dir .dry-runs
|
||||
gh valet dry-run azure-devops pipeline --pipeline-id PIPELINE-ID --output-dir dry-runs
|
||||
```
|
||||
4. Now, from the `./scripts` folder in your repository, run `valet dry-run` to see the output:
|
||||
3. Now, from the `valet` folder in your repository, run `gh valet dry-run` to see the output:
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
4. Valet will create a folder called `dry-runs` under the scripts folder that shows what will be migrated.
|
||||
4. Valet will create a folder called `dry-runs` under the `valet` folder that shows what will be migrated.
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
## View dry-run output
|
||||
The dry-run output will show you the GitHub Actions yml that will be migrated to GitHub.
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Migrate an Azure DevOps pipeline to GitHub Actions with a custom transformer
|
||||
In this lab, you will create a custom plugin that transforms some of the existing migration mapping and replaces it with your own mapping.
|
||||
In this lab, you will create a custom plugin that transforms some of the existing migration mapping and replaces it with your own mapping. Then use the `migrate` subcommand to migrate the pipeline. The `migrate` subcommand can be used to convert a pipeline to its GitHub Actions equivalent and then create a pull request with the contents.
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Identify the Azure DevOps pipeline ID to use](#identify-the-azure-devops-pipeline-id-to-use)
|
||||
- [Create a custom transformer](#create-a-custom-transformer)
|
||||
- [View the pull request](#view-the-pull-request)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -7,11 +12,24 @@ In this lab, you will create a custom plugin that transforms some of the existin
|
||||
2. Create or start a codespace in this repository (if not started)
|
||||
3. Complete the [Valet audit lab](valet-audit-lab.md).
|
||||
4. Complete the [Valet migrate lab](valet-migrate-lab.md).
|
||||
5. Verify or add the following values to the `./valet/.env.local` file. All values were created [here](/labs/azure_devops#readme)
|
||||
```
|
||||
GITHUB_ACCESS_TOKEN=<GithHub PAT generated>
|
||||
GITHUB_INSTANCE_URL=https://github.com/
|
||||
|
||||
AZURE_DEVOPS_PROJECT=<Project identified>
|
||||
AZURE_DEVOPS_ORGANIZATION=<Org identified>
|
||||
AZURE_DEVOPS_INSTANCE_URL=<DevOps instance>
|
||||
AZURE_DEVOPS_ACCESS_TOKEN=<Token Generated>
|
||||
```
|
||||
### Example ###
|
||||
|
||||

|
||||
|
||||
## Identify the Azure DevOps pipeline ID to use
|
||||
You will need the `valet-mapper-example` Azure DevOps pipeline ID to perform the migration
|
||||
1. Go to the `scripts/ValetBootstrap/pipelines` folder
|
||||
2. Open the `scripts/ValetBootstrap/pipelines/valet-mapper-example.config.json` file
|
||||
1. Go to the `valet/ValetBootstrap/pipelines` folder
|
||||
2. Open the `valet/ValetBootstrap/pipelines/valet-mapper-example.config.json` file
|
||||
3. Look for the `web - href` link
|
||||
4. At the end of the link is the pipeline ID. Copy or note the ID.
|
||||
|
||||
@@ -19,6 +37,7 @@ You will need the `valet-mapper-example` Azure DevOps pipeline ID to perform the
|
||||

|
||||
|
||||
## Create a custom transformer
|
||||
|
||||
To create a transformer, you need to create a Ruby file that looks as follows:
|
||||
``` ruby
|
||||
transform "azuredevopstaskname" do |item|
|
||||
@@ -26,7 +45,9 @@ transform "azuredevopstaskname" do |item|
|
||||
end
|
||||
```
|
||||
|
||||
We start by changing the function name to match the Azure DevOps task name `DotNetCoreCLI@2`.
|
||||
We start by creating a new folder called `plugin` under the `valet` folder in your repository. In there create a file called `DotNetCoreCLI.rb`.
|
||||
|
||||
Next change the function name to match the Azure DevOps task name `DotNetCoreCLI@2`.
|
||||
The way you find this name is by clicking the **view yaml** button at a task in the pipeline:
|
||||
|
||||
This results in the following code:
|
||||
@@ -37,13 +58,6 @@ transform "DotNetCoreCLI@2" do |item|
|
||||
```
|
||||
The parameter item is a collection of items than contain the properties of the original task that was retrieved from Azure DevOps.
|
||||
In this case we can see in the yaml that the properties that are set are `command` and `projects`.
|
||||
|
||||
This is what you can expect to find when we would dump the information. To determine what is in the item being passed, you can do the following:
|
||||
``` ruby
|
||||
transform "DotNetCoreCLI@2" do |item|
|
||||
puts item
|
||||
end
|
||||
```
|
||||
|
||||
Add the following code to the ruby file:
|
||||
``` Ruby
|
||||
@@ -72,13 +86,13 @@ end
|
||||
Run the `migrate` command with the transformer again and pass it the custom plugin. Look at the result and see if it results in a successful build.
|
||||
|
||||
```
|
||||
cd scripts
|
||||
valet migrate azure-devops pipeline --target-url https://github.com/GITHUB-ORG/GITHUB-REPO --pipeline-id PIPELINE-ID --custom-transformers plugin/DotNetCoreCLI.rb
|
||||
cd valet
|
||||
gh valet migrate azure-devops pipeline --target-url https://github.com/GITHUB-ORG/GITHUB-REPO --pipeline-id PIPELINE-ID --custom-transformers plugin/DotNetCoreCLI.rb --output-dir migrate
|
||||
```
|
||||
Now, from the `./scripts` folder in your repository, run `valet migrate` with the custom transformer to migrate the pipeline to GitHub Actions:
|
||||
Now, from the `./valet` folder in your repository, run `gh valet migrate` with the custom transformer to migrate the pipeline to GitHub Actions:
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
## View the pull request
|
||||
The migrate output will show you the pull request on GitHub. Note here that the checks on the pull request all passed!
|
||||
|
||||
@@ -1,16 +1,34 @@
|
||||
# Migrate an Azure DevOps pipeline to GitHub Actions
|
||||
In this lab, you will use the Valet `migrate` command to migrate an Azure DevOps pipeline to GitHub Actions.
|
||||
In this lab, you will use the Valet `migrate` command to migrate an Azure DevOps pipeline to GitHub Actions. The `migrate` subcommand can be used to convert a pipeline to its GitHub Actions equivalent and then create a pull request with the contents.
|
||||
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Identify the Azure DevOps pipeline ID to use](#identify-the-azure-devops-pipeline-id-to-use)
|
||||
- [Perform a migration](#perform-a-migration)
|
||||
- [View the pull request](#view-the-pull-request)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment
|
||||
2. Create or start a codespace in this repository (if not started)
|
||||
3. Completed the [Valet audit lab](valet-audit-lab.md).
|
||||
4. Verify or add the following values to the `./valet/.env.local` file. All values were created [here](/labs/azure_devops#readme)
|
||||
```
|
||||
GITHUB_ACCESS_TOKEN=<GithHub PAT generated>
|
||||
GITHUB_INSTANCE_URL=https://github.com/
|
||||
|
||||
AZURE_DEVOPS_PROJECT=<Project identified>
|
||||
AZURE_DEVOPS_ORGANIZATION=<Org identified>
|
||||
AZURE_DEVOPS_INSTANCE_URL=<DevOps instance>
|
||||
AZURE_DEVOPS_ACCESS_TOKEN=<Token Generated>
|
||||
```
|
||||
### Example ###
|
||||
|
||||

|
||||
|
||||
## Identify the Azure DevOps pipeline ID to use
|
||||
You will need a pipeline ID to perform the migration
|
||||
1. Go to the `scripts/ValetBootstrap/pipelines` folder
|
||||
2. Open the `scripts/ValetBootstrap/pipelines/valet-pipeline1.config.json` file
|
||||
1. Go to the `valet/ValetBootstrap/pipelines` folder
|
||||
2. Open the `valet/ValetBootstrap/pipelines/valet-pipeline1.config.json` file
|
||||
3. Look for the `web - href` link
|
||||
4. At the end of the link is the pipeline ID. Copy or note the ID.
|
||||
|
||||
@@ -22,25 +40,27 @@ You will need a pipeline ID to perform the migration
|
||||
You will use the codespace preconfigured in this repository to perform the migration.
|
||||
|
||||
1. Navigate to the codespace Visual Studio Code terminal
|
||||
2. Verify you are in the scripts directory
|
||||
2. Verify you are in the valet directory
|
||||
3. Copy the following command and replace:
|
||||
- `GITHUB-ORG` with the name of your organization.
|
||||
- `GITHUB-REPO` with the name of your repository.
|
||||
- `PIPELINE-ID` with your pipeline ID.
|
||||
4. Now, from the `./scripts` folder in your repository, run `valet migrate` to migrate the pipeline to GitHub Actions.
|
||||
4. Now, from the `./valet` folder in your repository, run `valet migrate` to migrate the pipeline to GitHub Actions.
|
||||
```
|
||||
cd scripts
|
||||
valet migrate azure-devops pipeline --target-url https://github.com/GITHUB-ORG/GITHUB-REPO --pipeline-id PIPELINE-ID
|
||||
cd valet
|
||||
gh valet migrate azure-devops pipeline --target-url https://github.com/GITHUB-ORG/GITHUB-REPO --pipeline-id PIPELINE-ID --output-dir migrations
|
||||
```
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
|
||||
5. Valet will create a pull request directly to your GitHub repository.
|
||||
6. Click the green pull request link in the output of the migrate command. See below.
|
||||
|
||||
### Example
|
||||

|
||||

|
||||
|
||||
|
||||
## View the pull request
|
||||
The migrate output will show you the pull request on GitHub.
|
||||
|
||||
Reference in New Issue
Block a user