In this lab you will use the dry-run
command to convert an Azure DevOps pipeline to its equivalent GitHub Actions workflow.
- Followed the steps here to set up your GitHub Codespaces environment and bootstrap an Azure DevOps project.
- Completed the configure lab.
- Completed the audit lab.
You will perform a dry run for a pipeline in the bootstrapped Azure DevOps project. Answer the following questions before running this command:
-
What is the id of the pipeline to convert?
- :pipeline_id. This id can be found by:
- Navigating to the build pipelines in the bootstrapped Azure DevOps project https://dev.azure.com/:organization/:project/_build
- Selecting the pipeline with the name "pipeline1"
- Inspecting the URL to locate the pipeline id https://dev.azure.com/:organization/:project/_build?definitionId=:pipeline_id
- :pipeline_id. This id can be found by:
-
Where do you want to store the result?
- tmp/dry-run. This can be any path within the working directory from which GitHub Actions Importer commands are executed.
-
Navigate to your codespace terminal.
-
Run the following command from the root directory:
gh actions-importer dry-run azure-devops pipeline --pipeline-id :pipeline_id --output-dir tmp/dry-run
-
The command will list all the files written to disk when the command succeeds.
-
View the converted workflow:
- Find
tmp/dry-run/pipelines/lab-testing/pipelines/pipeline1/.github/workflows
in the file explorer pane in your codespace. - Click
pipeline1.yml
to open.
- Find
The files generated from the dry-run
command represent the equivalent Actions workflow for the given Azure DevOps pipeline. The Azure DevOps pipeline and converted workflow can be seen below:
Azure DevOps pipeline 👇
trigger:
- main
pool:
vmImage: windows-latest
steps:
- script: echo Hello, I am pipeline 1!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
Converted workflow 👇
name: actions-importer-bootstrap/pipelines/pipeline1
on:
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Run a one-line script
run: echo Hello, I am pipeline 1!
- name: Run a multi-line script
run: |-
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
Despite these two pipelines using different syntax they will function equivalently.
Use custom transformers to customize GitHub Actions Importer's behavior