From 03753a327f74a858d2415eb6f9ace961d13266a7 Mon Sep 17 00:00:00 2001 From: dkalmin Date: Wed, 25 May 2022 10:57:51 -0700 Subject: [PATCH] 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 * Update readme.md * Update azure_devops/readme.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-audit-lab.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-audit-lab.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-migrate-custom-lab.md Co-authored-by: Ethan Dennis * Update azure_devops/valet-dry-run-lab.md Co-authored-by: Ethan Dennis * 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 * Update azure_devops/valet-audit-lab.md Co-authored-by: David Hathaway * Update valet-audit-lab.md * Update valet-dry-run-lab.md * Update azure_devops/valet-dry-run-lab.md Co-authored-by: David Hathaway * Update azure_devops/valet-migrate-lab.md Co-authored-by: David Hathaway * 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 Co-authored-by: David Hathaway --- .devcontainer/devcontainer.json | 7 +- .devcontainer/setupcodespace.sh | 45 +++ .github/workflows/valetbsazdo.yml | 2 +- .gitignore | 353 ++++++++++++++++++++++ azure_devops/bootstrap/azDevOps.ps1 | 106 +++++-- azure_devops/bootstrap/updateEnvs.ps1 | 21 -- azure_devops/readme.md | 127 ++++---- azure_devops/valet-audit-lab.md | 44 ++- azure_devops/valet-dry-run-lab.md | 49 +-- azure_devops/valet-migrate-custom-lab.md | 44 ++- azure_devops/valet-migrate-lab.md | 38 ++- valet/{.env.local => .env.local.template} | 1 + valet/valet | 27 -- valet/valet-update | 10 - 14 files changed, 681 insertions(+), 193 deletions(-) create mode 100644 .devcontainer/setupcodespace.sh create mode 100644 .gitignore delete mode 100644 azure_devops/bootstrap/updateEnvs.ps1 rename valet/{.env.local => .env.local.template} (81%) delete mode 100644 valet/valet delete mode 100644 valet/valet-update diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3e2e04b..d3ad635 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,12 +15,7 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "GitHub.vscode-pull-request-github", - "ms-vscode.azure-account", - "ms-vscode.azurecli", - "ms-azure-devops.azure-pipelines", "ms-azuretools.vscode-docker", - "ms-vscode.powershell" ], - "postCreateCommand": "docker login ghcr.io/valet-customers --username ${GITHUB_USER} --password ${VALET_PASSWORD} && docker pull ghcr.io/valet-customers/valet-cli:latest && chmod +x ./valet/valet-update && chmod +x ./valet/valet && pwsh ./azure_devops/bootstrap/updateEnvs.ps1 -ghPAT ${VALET_PASSWORD} -azdoPAT ${AZDO_TOKEN} -org ${AZDO_ORG} -proj ${AZDO_PROJECT} || echo 'Could not auto-build. Skipping.' " + "postCreateCommand": "sudo bash .devcontainer/setupcodespace.sh ${VALET_GHCR_PASSWORD} ${AZURE_DEVOPS_PROJECT} ${AZURE_DEVOPS_ORGANIZATION} ${AZURE_DEVOPS_ACCESS_TOKEN} ${GITHUB_USER} 'https://github.com/' && gh extension install github/gh-valet || echo 'Could not auto-build. Skipping.' " } diff --git a/.devcontainer/setupcodespace.sh b/.devcontainer/setupcodespace.sh new file mode 100644 index 0000000..409335a --- /dev/null +++ b/.devcontainer/setupcodespace.sh @@ -0,0 +1,45 @@ +#!/bin/bash +echo "Starting setupcodespace.sh" + +azdoProject="AZURE_DEVOPS_PROJECT=" +azdoOrg="AZURE_DEVOPS_ORGANIZATION=" +azdoInstance="AZURE_DEVOPS_INSTANCE_URL=" +ghAccess="GITHUB_ACCESS_TOKEN=" +azdoAccess="AZURE_DEVOPS_ACCESS_TOKEN=" +ghInstanceUrl="GITHUB_INSTANCE_URL=" + +cat valet/.env.local + +if [ -z "$1" -o -z "$5" ] +then + echo "Error: Docker Pull Valet not executing because GITHUB_USER and/or VALET_PASSWORD not set" +else + docker login ghcr.io/valet-customers --username $5 --password $1 + docker pull ghcr.io/valet-customers/valet-cli:latest + echo "Success: Docker Pull Valet completed" + +fi + +if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" -o -z "$6" ] +then + value=`cat valet/.env.local.template` + echo "$value" > valet/.env.local + echo "Error: Set envars not set, valid values not passed in" +else + azdoInstanceUrl="https://dev.azure.com/$3" + + value=`cat valet/.env.local.template` + + result="${value/$azdoProject/$azdoProject$2}" + result="${result/$azdoOrg/$azdoOrg$3}" + result="${result/$azdoInstance/$azdoInstance$azdoInstanceUrl}" + result="${result/$ghAccess/$ghAccess$1}" + result="${result/$azdoAccess/$azdoAccess$4}" + result="${result/$ghInstanceUrl/$ghInstanceUrl$6}" + + echo "$result" > valet/.env.local + echo "Success: set envars in valet/.env.local" + +fi + +echo "Finished setupcodespace.sh" diff --git a/.github/workflows/valetbsazdo.yml b/.github/workflows/valetbsazdo.yml index 46d9750..bdcda6f 100644 --- a/.github/workflows/valetbsazdo.yml +++ b/.github/workflows/valetbsazdo.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v2 - name: Run powershell file to bootstrap Azure DevOps env: - AZDOPATTOUSE: ${{ secrets.AZDOPAT }} + AZDOPATTOUSE: ${{ secrets.AZURE_DEVOPS_ACCESS_TOKEN }} ROOTFOLDER: ${{ github.workspace }} shell: pwsh run: | diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4adbb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,353 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# valet files +valet/.env*local diff --git a/azure_devops/bootstrap/azDevOps.ps1 b/azure_devops/bootstrap/azDevOps.ps1 index 626de9e..8e36704 100644 --- a/azure_devops/bootstrap/azDevOps.ps1 +++ b/azure_devops/bootstrap/azDevOps.ps1 @@ -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" diff --git a/azure_devops/bootstrap/updateEnvs.ps1 b/azure_devops/bootstrap/updateEnvs.ps1 deleted file mode 100644 index 04bbaec..0000000 --- a/azure_devops/bootstrap/updateEnvs.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -param ( - [String]$proj = "ValetBootstrapper", - [String]$org = "microsoft-bootcamp", - [String]$ghPAT = "dkalmintest", - [String]$azdoPAT = "dkalmin@github.com" - ) - -[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 diff --git a/azure_devops/readme.md b/azure_devops/readme.md index 1c3ebdb..d07ac10 100644 --- a/azure_devops/readme.md +++ b/azure_devops/readme.md @@ -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 ### ![runaction](https://user-images.githubusercontent.com/26442605/167679930-9bdf6f4f-2e94-4145-aed3-8ee3e8e91d90.png) @@ -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 ### +![gh-valet-version](https://user-images.githubusercontent.com/26442605/170106559-e69e669f-a1f6-4c2c-8998-3f089b899704.png) ## 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 + ![linktolcickauth](https://user-images.githubusercontent.com/26442605/169588015-9414404f-82b6-4d0f-89d4-5f0e6941b029.png) + - Restart Codespace after clicking the link +- Verify Valet CLI is installed and working diff --git a/azure_devops/valet-audit-lab.md b/azure_devops/valet-audit-lab.md index 59f127a..cbd9ca3 100644 --- a/azure_devops/valet-audit-lab.md +++ b/azure_devops/valet-audit-lab.md @@ -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= +GITHUB_INSTANCE_URL=https://github.com/ + +AZURE_DEVOPS_PROJECT= +AZURE_DEVOPS_ORGANIZATION= +AZURE_DEVOPS_INSTANCE_URL= +AZURE_DEVOPS_ACCESS_TOKEN= +``` +### Example ### + +![envlocal](https://user-images.githubusercontent.com/26442605/169069638-0bfa8f89-eaa9-423b-b2b7-447248e63e2b.png) ## 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 -![runaudit](https://user-images.githubusercontent.com/26442605/160930617-d4d2f4a8-7b39-47d6-ab2c-60868cb56e5f.png) +![valet-audit-1](https://user-images.githubusercontent.com/26442605/169615028-696dad13-ff83-41a7-b475-0ab8c0bbcd65.png) 4. Valet displays green log files to indicate a successful audit ### Example -![audit-output](https://user-images.githubusercontent.com/26442605/161104845-3d9d7493-794f-4787-9a89-3dd3c15a8a8d.png) +![valet-audit-2](https://user-images.githubusercontent.com/26442605/169615218-a8a3199d-a436-4d70-8c1e-17a61b089eb6.png) ## 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 -![audit-summary](https://user-images.githubusercontent.com/26442605/161105335-4c38ea73-b5a5-4edc-9d89-d6febcae46d4.png) +![valet-audit-3](https://user-images.githubusercontent.com/26442605/169615428-26f7a962-2064-46d0-8206-ea930109b252.png) ## 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 -![audit-pipelines](https://user-images.githubusercontent.com/26442605/161105649-dd20235d-bb98-4949-baa3-dac561427257.png) +![valet-audit-4](https://user-images.githubusercontent.com/26442605/169615630-8d700081-c631-4b2a-ab1c-e52503f7838f.png) + diff --git a/azure_devops/valet-dry-run-lab.md b/azure_devops/valet-dry-run-lab.md index 1303a0f..73730d4 100644 --- a/azure_devops/valet-dry-run-lab.md +++ b/azure_devops/valet-dry-run-lab.md @@ -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= +GITHUB_INSTANCE_URL=https://github.com/ + +AZURE_DEVOPS_PROJECT= +AZURE_DEVOPS_ORGANIZATION= +AZURE_DEVOPS_INSTANCE_URL= +AZURE_DEVOPS_ACCESS_TOKEN= +``` +### Example ### + +![envlocal](https://user-images.githubusercontent.com/26442605/169069638-0bfa8f89-eaa9-423b-b2b7-447248e63e2b.png) ## 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 -![configpipelineid](https://user-images.githubusercontent.com/26442605/161106098-3b9b05ec-ee5d-4b21-ab07-9f05f8cf1d98.png) - +![valet-dr-5](https://user-images.githubusercontent.com/26442605/169616920-7c407adc-0c4e-4104-9046-d1d2ecdd6edf.png) ## 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 -![dryrun-ex2](https://user-images.githubusercontent.com/26442605/161107259-39076729-2ac8-4104-8170-11061b732593.png) +![valet-dr-1](https://user-images.githubusercontent.com/26442605/169616149-46c2d743-47fe-4061-a48a-7f21442624cb.png) -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 -![dryrun-output](https://user-images.githubusercontent.com/26442605/161106810-6a48b261-8099-449b-a41c-3d1e0903485a.png) +![valet-dr-2](https://user-images.githubusercontent.com/26442605/169616265-176a19fd-3071-44fc-bff7-866a172afc57.png) ## View dry-run output The dry-run output will show you the GitHub Actions yml that will be migrated to GitHub. ### Example -![dryrunyml](https://user-images.githubusercontent.com/26442605/161108244-28da94d6-c28d-4484-bc08-cb3392d7745e.png) +![valet-dr-3](https://user-images.githubusercontent.com/26442605/169616486-fd5512fa-0761-45fe-a252-5b2ef0926a04.png) + diff --git a/azure_devops/valet-migrate-custom-lab.md b/azure_devops/valet-migrate-custom-lab.md index 675eeb5..ccf7a3b 100644 --- a/azure_devops/valet-migrate-custom-lab.md +++ b/azure_devops/valet-migrate-custom-lab.md @@ -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= +GITHUB_INSTANCE_URL=https://github.com/ + +AZURE_DEVOPS_PROJECT= +AZURE_DEVOPS_ORGANIZATION= +AZURE_DEVOPS_INSTANCE_URL= +AZURE_DEVOPS_ACCESS_TOKEN= +``` +### Example ### + +![envlocal](https://user-images.githubusercontent.com/26442605/169069638-0bfa8f89-eaa9-423b-b2b7-447248e63e2b.png) ## 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 ![configpipelineid](https://user-images.githubusercontent.com/26442605/161106098-3b9b05ec-ee5d-4b21-ab07-9f05f8cf1d98.png) ## 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 -![mapper-ex2](https://user-images.githubusercontent.com/26442605/161116637-15c01950-ede0-4992-876b-6a3fe5688723.png) +![valet-cm-1](https://user-images.githubusercontent.com/26442605/169618556-7c79b34b-6d4c-48d5-98e5-7f8d771117a5.png) ## 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! diff --git a/azure_devops/valet-migrate-lab.md b/azure_devops/valet-migrate-lab.md index 8ff2dcc..d51dd6d 100644 --- a/azure_devops/valet-migrate-lab.md +++ b/azure_devops/valet-migrate-lab.md @@ -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= +GITHUB_INSTANCE_URL=https://github.com/ + +AZURE_DEVOPS_PROJECT= +AZURE_DEVOPS_ORGANIZATION= +AZURE_DEVOPS_INSTANCE_URL= +AZURE_DEVOPS_ACCESS_TOKEN= +``` +### Example ### + +![envlocal](https://user-images.githubusercontent.com/26442605/169069638-0bfa8f89-eaa9-423b-b2b7-447248e63e2b.png) ## 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 -![migrate-command](https://user-images.githubusercontent.com/26442605/161110277-45d9fff0-9d45-4946-a2a7-8f82fbb5d43f.png) +![valet-migrate-1](https://user-images.githubusercontent.com/26442605/169617557-289cee54-0116-4d13-8e6f-a9d0508259e1.png) + 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 -![migrateoutput](https://user-images.githubusercontent.com/26442605/167672012-0580a215-29d4-4aff-a730-3e769414b1b7.png) +![valet-migrate-5](https://user-images.githubusercontent.com/26442605/169617699-ce0c0720-8830-46ed-811d-c2fe1ccf06ea.png) + ## View the pull request The migrate output will show you the pull request on GitHub. diff --git a/valet/.env.local b/valet/.env.local.template similarity index 81% rename from valet/.env.local rename to valet/.env.local.template index 0c10345..ce4ca6f 100644 --- a/valet/.env.local +++ b/valet/.env.local.template @@ -4,3 +4,4 @@ GITHUB_INSTANCE_URL= AZURE_DEVOPS_PROJECT= AZURE_DEVOPS_ORGANIZATION= AZURE_DEVOPS_INSTANCE_URL= +AZURE_DEVOPS_ACCESS_TOKEN= diff --git a/valet/valet b/valet/valet deleted file mode 100644 index 025b8cf..0000000 --- a/valet/valet +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# Version 1.1.1 - -VALET_REGISTRY=${VALET_REGISTRY:="ghcr.io"} -VALET_IMAGE=${VALET_IMAGE:-"$VALET_REGISTRY/valet-customers/valet-cli"} -VALET_IMAGE_VERSION=${VALET_IMAGE_VERSION:-"latest"} - -VALET_TOKEN_FILE=${VALET_TOKEN_FILE:-".env.local"} -VALET_ENV_VARS=('GITHUB_ACCESS_TOKEN' 'AZURE_DEVOPS_ACCESS_TOKEN' 'GITHUB_INSTANCE_URL' 'JENKINSFILE_ACCESS_TOKEN' 'JENKINS_USERNAME' 'JENKINS_ACCESS_TOKEN' 'JENKINS_INSTANCE_URL' 'TRAVIS_CI_ACCESS_TOKEN' 'TRAVIS_CI_INSTANCE_URL' 'TRAVIS_CI_SOURCE_GITHUB_ACCESS_TOKEN' 'TRAVIS_CI_SOURCE_GITHUB_INSTANCE_URL' 'YAML_VERBOSITY' 'HTTP_PROXY' 'HTTPS_PROXY' 'NO_PROXY' 'OCTOKIT_PROXY' 'OCTOKIT_SSL_VERIFY_MODE') -VALET_LOCAL_FOLDER=${VALET_LOCAL_FOLDER:-$(pwd)} - -if [[ -z "${DOCKER_OPTIONS+x}" ]]; then - DOCKER_OPTIONS="-t" -fi - -if [[ -e "$VALET_TOKEN_FILE" ]]; then - dockerArgs="--env-file $VALET_TOKEN_FILE" -fi - -for varName in ${VALET_ENV_VARS[*]}; do - if [ "${!varName}" != "" ]; then - dockerArgs=$dockerArgs" --env $varName" - fi -done - -MSYS_NO_PATHCONV=1 docker run --rm $dockerArgs $DOCKER_OPTIONS -v "$VALET_LOCAL_FOLDER"":/data" "$VALET_IMAGE":"$VALET_IMAGE_VERSION" "$@" diff --git a/valet/valet-update b/valet/valet-update deleted file mode 100644 index 2467924..0000000 --- a/valet/valet-update +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# Version 1.1.0 - -VALET_REGISTRY=${VALET_REGISTRY:="ghcr.io"} -VALET_IMAGE=${VALET_IMAGE:-"$VALET_REGISTRY/valet-customers/valet-cli"} - -docker login $VALET_REGISTRY - -docker pull $VALET_IMAGE:latest