# Github Actions Workflow to Trigger Azure Devops Pipelines to Execute Terraform Code
name: Trigger Azure Pipelines
# Controls when the workflow will run
on:
# Allows you
# Github Actions Workflow to Trigger Azure Devops Pipelines to Execute Terraform Code.
name: Trigger Azure Pipelines
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a job called "build-in-actions-workflow"
build-in-actions-workflow:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# This workflow contains a job called "deploy-using-azure-pipelines"
deploy-using-azure-pipelines:
# This job is dependent on the previous job "build-in-actions-workflow"
needs: build-in-actions-workflow
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: 'Trigger an Azure Pipeline to Register Azure Providers in a Subscription using Terraform'
uses: Azure/pipelines@releases/v1
with:
azure-devops-project-url: 'https://dev.azure.com/ArindamMitra0251/AMCLOUD'
azure-pipeline-name: 'Az-Provider-Registration'
azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}'
EXPLANATION:-
Below follows the step by step explanation of Github Actions workflow: -
Name of the workflow.
name: Trigger Azure Pipelines
We need to Control how the workflow will run. with below, it will allow you to run this workflow manually from the Actions tab.
on:
workflow_dispatch:
A workflow run is made up of one or more jobs that can run sequentially or in parallel.
jobs:
The Name of the first job is "build-in-actions-workflow". This Job will run on the runner "ubuntu-latest".
build-in-actions-workflow:
runs-on: ubuntu-latest
"Steps" represent a sequence of tasks that will be executed as part of the job. "actions/checkout@v3" task Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
steps:
- uses: actions/checkout@v3
The Name of the Second job is "deploy-using-azure-pipelines". This Job is dependent on the First job "build-in-actions-workflow" and will run on the runner "ubuntu-latest".
The Name of the "Step" in the Second Job is "Trigger an Azure Pipeline to Register Azure Providers in a Subscription using Terraform". "Azure/pipelines@releases/v1" task is used to trigger Azure Devops Pipelines from Github Actions Workflow. In order to do so, below is required -
REQUIREMENTS
Azure Devops Project URL
Azure Pipeline Name
Generate PAT in Azure Devops
Store Azure Devops PAT as Github Repository Secret
steps:
- name: 'Trigger an Azure Pipeline to Register Azure Providers in a Subscription using Terraform'
uses: Azure/pipelines@releases/v1
with:
azure-devops-project-url: 'https://dev.azure.com/ArindamMitra0251/AMCLOUD'
azure-pipeline-name: 'Az-Provider-Registration'
azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}'
NOTE:-
1. All the below YAML (Pipeline) and Terraform codes resides in Azure Devops Project repository.
2. The explanation of the YAML (Pipeline) and Terraform codes are out of scope as mentioned above.
Top comments (0)