diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d3ad635..8c3f8c2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,5 +17,6 @@ "extensions": [ "ms-azuretools.vscode-docker", ], + "onCreateCommand": 'echo "export GITHUB_ACCESS_TOKEN=$VALET_GHCR_PASSWORD" >> ~/.bashrc', "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 index 409335a..c98469a 100644 --- a/.devcontainer/setupcodespace.sh +++ b/.devcontainer/setupcodespace.sh @@ -8,8 +8,6 @@ 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" @@ -17,29 +15,14 @@ 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 +value=`cat valet/.env.local.template` +echo "$value" > valet/.env.local + 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" - + echo "Error: Set envars not set, valid values not passed in. You will have to manually use the valet/.env.local folder" fi echo "Finished setupcodespace.sh" diff --git a/azure_devops/readme.md b/azure_devops/readme.md index d07ac10..105e366 100644 --- a/azure_devops/readme.md +++ b/azure_devops/readme.md @@ -12,20 +12,22 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you ## Repo template -1. Click `Use this template` to create this repository inside your GitHub organization. +1. Verify you are in your own Repository created from the landing page [Valet Labs](https://github.com/valet-customers/labs). ## 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 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. +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 different 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`. + - Click your `Account management` icon + - Click `user settings` + - Click `Personal access tokens`. - Select `+ New Token` - Name your token, select the organization where you want to use the token, and then set your token to automatically expire after a set number of days. - - Select the following scopes: + - Select the following scopes (Click `Show more scopes` if you don't see all of the below): - Agents Pool: `Read` - Build: `Read & Execute` - Code: `Read & Write` @@ -57,7 +59,7 @@ 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 +- Click `New Repository Secret` to create a new secret - Name the secret as noted above - Paste in the value noted above - Click `Add Secret` @@ -67,14 +69,14 @@ 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: +Steps to create the Actions 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 +- Paste in the value noted above - Click `Add Secret` ## Azure DevOps project creation @@ -97,14 +99,14 @@ Run the Actions workflow: ## Use Valet with a codespace 1. Start the codespace - - Click the `Code` button above repository + - Click the `Code` with button down arrow above repository on the repository's landing page. - Click the `Codespaces` tab - - Click `New Codespace` + - Click `Create codespaces on main` to create the codespace. If you are in another branch then the `main` branch, the codespace will button will have the current branch specified. - Wait a couple minutes, then verify that the codespace starts up. Once it is fully booted up, the termininal should be present. 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) + - Run `gh valet version` in the Visual Studio Code terminal and verify the output looks like the below image. Note the valet version will be different than below as the latest version gets pulled down. + - If `gh valet version` did not produce a similar image with a version 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 ### diff --git a/azure_devops/valet-audit-lab.md b/azure_devops/valet-audit-lab.md index 5ae8e8a..40aa2dc 100644 --- a/azure_devops/valet-audit-lab.md +++ b/azure_devops/valet-audit-lab.md @@ -5,24 +5,12 @@ In this lab, you will use Valet to `audit` an Azure DevOps organization. The `au - [Perform an audit](#perform-an-audit) - [View audit output](#view-audit-output) - [Review the pipelines](#review-the-pipelines) +- [Next Lab](#next-lab) ## Prerequisites -1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment +1. Follow all steps [here](../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. @@ -60,3 +48,5 @@ The `audit` command grabs the yml, classic, and release pipelines from Azure Dev View the source yml and the proposed GitHub yml ![valet-audit-4](https://user-images.githubusercontent.com/26442605/169615630-8d700081-c631-4b2a-ab1c-e52503f7838f.png) +### Next Lab +[Dry run the migration of an Azure DevOps pipeline to GitHub Actions](valet-dry-run-lab.md) diff --git a/azure_devops/valet-dry-run-lab.md b/azure_devops/valet-dry-run-lab.md index fbdea4d..36ae851 100644 --- a/azure_devops/valet-dry-run-lab.md +++ b/azure_devops/valet-dry-run-lab.md @@ -5,30 +5,18 @@ In this lab, you will use the `valet dry-run` command to convert an Azure DevOps - [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) +- [Next Lab](#next-lab) ## Prerequisites -1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment +1. Follow all steps [here](../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 `valet/ValetBootstrap/pipelines` folder -2. Open the `valet/ValetBootstrap/pipelines/valet-pipeline1.json` file +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. @@ -60,3 +48,5 @@ The dry-run output will show you the GitHub Actions yml that will be migrated to ### Example ![valet-dr-3](https://user-images.githubusercontent.com/26442605/169616486-fd5512fa-0761-45fe-a252-5b2ef0926a04.png) +### Next Lab +[Migrate an Azure DevOps pipeline to GitHub Actions](valet-migrate-lab.md) diff --git a/azure_devops/valet-migrate-custom-lab.md b/azure_devops/valet-migrate-custom-lab.md index 97c3654..8420a0e 100644 --- a/azure_devops/valet-migrate-custom-lab.md +++ b/azure_devops/valet-migrate-custom-lab.md @@ -8,23 +8,10 @@ In this lab, you will create a custom plugin that transforms some of the existin ## Prerequisites -1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment +1. Follow all steps [here](../azure_devops#readme) to set up your environment 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 @@ -34,7 +21,7 @@ You will need the `valet-mapper-example` Azure DevOps pipeline ID to perform the 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) +![mapperprops](https://user-images.githubusercontent.com/26442605/175090567-525b97a7-60d2-41b7-9dcd-d559ca1c5bd7.png) ## Create a custom transformer diff --git a/azure_devops/valet-migrate-lab.md b/azure_devops/valet-migrate-lab.md index 5053627..a068f15 100644 --- a/azure_devops/valet-migrate-lab.md +++ b/azure_devops/valet-migrate-lab.md @@ -5,25 +5,13 @@ In this lab, you will use the Valet `migrate` command to migrate an Azure DevOps - [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) +- [Next Lab](#next-lab) ## Prerequisites -1. Follow all steps [here](/labs/azure_devops#readme) to set up your environment +1. Follow all steps [here](../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 @@ -67,3 +55,6 @@ The migrate output will show you the pull request on GitHub. ### Example ![migrate-pr](https://user-images.githubusercontent.com/26442605/161110724-f39d9cb9-1992-44c5-bea5-da2fcebb074c.png) + +### Next Lab +[Migrate an Azure DevOps pipeline to GitHub Actions with a custom transformer](valet-migrate-custom-lab.md) diff --git a/readme.md b/readme.md index d5069b2..9577b17 100644 --- a/readme.md +++ b/readme.md @@ -1,14 +1,19 @@ # Welcome to Valet labs! -These Valet labs let you test-drive Valet by bootstrapping the environment of your choosing. Below are the specific functions of the labs. +These Valet labs let you test-drive Valet by bootstrapping the environment of your choosing. The steps to get started with the Valet labs are: +1. Create your own GitHub Repository. See [Prerequisites](#prerequisites) below. +2. Bootstrap your environment. The default page of the lab of your choosing will detail how to configure and run the action to bootstrap the environment. Currently these labs support [Azure DevOps](azure_devops). +3. Run Valet via Codespaces. The codespace has docker running and will update to the latest Valet environment. +4. Proceed with running the labs! -## Bootstrap your environment -The first step toward setting up a bootstrapped environment is to choose what platform to run Valet against. Currently these labs support Azure DevOps. The default page of the lab of your choosing will detail how to configure and run the action to bootstrap the environment. +# Prerequisites +1. Create your own GitHub Repository in your own GitHub Organization or under your user with Codespaces enabled using this Repository as a template. To do so: + - Navigate to the top of this Repository click `Use this template` + - Select the owner of the new Reposiotry. It could be your personal username or an Organization you belong to. + - Name the Repository + - Click `Create repository froom template` + - Proceed to the labs inside of your new Repository. -## Configure and run Codespaces -After you have an environment bootstrapped, you run Valet via Codespaces. The codespace has docker running and will update to the latest Valet environment. - -## Labs -Once you have a bootstrapped environment and Valet running via Codespaces, you can proceed to the labs. +![createtemplate](https://user-images.githubusercontent.com/26442605/174847176-0e515fd3-8107-43e0-af33-70b1ece36d3b.png) ## Environments to bootstrap - [Azure DevOps](azure_devops)