TABLE OF CONTENT
1. Introduction 2. Introduction 2. Example of setting up a Workflow Prerequisites Introduction to Terraform6. Conclusion7. CloudThat 8. FAQs 1. Introduction
GitHub Actions is a continuous-integration and continuous delivery (CI/CD), tool that is offered by GitHub. It is open-source, one of the most popular tools, and allows you to automate your build and test. It’s a fast deployment tool that has well-founded security and less overhead. You can also create workflows quickly.
Let’s say we want to create an automated workflow that is activated when an issue has been raised. The workflow will have multiple jobs in its virtual machine run and performs one or several steps that you specify or run an action. What are these workflows, events, and jobs? ?
2. The Components of GitHub Activities
Workflows: A workflow is an automated process that runs one job or more. A workflow can be defined in YAML files in your repository. It will run when it is triggered by a particular event. Multiple workflows can be created in a repository for different roles.
Events: An activity in your repository that triggers a workflow, such as pushing a commit or creating pull requests, are called events.
Jobs: A job is a set or instructions that are executed by the runner. An instruction can be either a script or a running action. Jobs can be executed in a sequence or simultaneously. Because they are dependent on one another, we can also share data. Job dependencies can be managed with other jobs. By default, jobs are executed in parallel without dependencies.
Actions: This is a custom application that can reduce repetitive code in workflow files. You can either use the actions in the GitHub marketplace or create your own actions.
Runners: This is the backend server that runs the workflow. Each workflow will be executed using a newly provisioned run.
Here you can dive into the GitHub actions in depth
3. Example of setting up a Workflow
You might set up a workflow to be triggered when the code gets pushed into the main branches. The workflow jobs that automate the deployment of Azure resources.
You will need a GitHub account. Actions should be enabled.
Azure credentialsAzure Tenant ID
Azure subscription ID
We require an Azure Service Principle with a Contributor Role
An azure Service Principle’s ClientID, Secrets. This service principle will be used by Terraform to authenticate with Azure when creating resources
This setup will use an Azure storage account for my terraform backend. I have created a resource team with a storage account, container, and container.
Terraform configuration files are used to create resources. This is how I create the azure resources. However, you can deploy resources to any cloud you choose.
5. Introduction to Terraform
Terraform is an Infrastructure as a Code tool. It allows you to create and manage cloud and on-premises resources using human-readable configuration files that you can share, reuse and version. The configuration files are written using terraform HCL ( Hashicorp Configuration Language).
Let’s get started by creating a repository to store our pipeline.
Log in to your GitHub account to create a repository
Your terraform code should be uploaded to the repository. Here is my Terraform code. I have modules to create an Azure Virtual Network subnet, Resource group, and security group for the development environment.
Next, add the secrets of the service principle to your repository. Go to Settings in your repository. Click on Secrets to add a new repository secret. Click on Add secret to add a name and value to your secret. Continue this process until you have all required credentials
Now we need to enable GitHub Actions on our account. To do this navigate to your repository and click