Wednesday, 3 August 2022

CI/CD with GitHub Actions

 If you are working with GitHub Actions, you might too get confused with the term Workflow vs Actions. Here I’m gonna explain the difference as well as also giving you example to create your first CI/CD, even if you have never done it before.

Workflow is all the tasks which has to be performed when the event (in our case, push event on the branch repo) occurs.

name: Build and Run tests#define variables
env:
DOTNET_VERSION:'6.0.x'

An Event is something that happens in a GitHub repository. i.e. Push, Create, delete, deployment, fork, pull_request, workflow_dispatch etc.

name: Build and Run tests#define variables
env:
DOTNET_VERSION:'6.0.x'
on:
push:
branches:
- master
workflow_dispatch:

Job is a series of steps inside the workflow which are executed. Each step is either a script to be executed or an action that would run.

name: Build and Run tests#define variables
env:
DOTNET_VERSION:'6.0.x'
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
environment: Test

The Runners are the process on the server that runs the workflow. Runners are hosted in the cloud and we specify the name of the runner for job using runs-on syntax.

name: Build and Run tests#define variables
env:
DOTNET_VERSION:'6.0.x'
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
environment: Production
name: Build and Run tests#define variables
env:
DOTNET_VERSION:'6.0.x'
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
environment: Production
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Build projects
run: |
dotnet build --configuration Release
- name: Test with the dotnet CLI
run: dotnet test

Bonus

Follow me here for my next article on CI/CD with GitHub Actions to deploy Application to Azure App Service

No comments:

Post a Comment