CI/CD using GitHub Actions Workflow directly from Visual Studio

CI/CD using GitHub Actions Workflow directly from Visual Studio

GitHub Actions makes it extremely easy for CI/CD to build, test, and deploy your code right from GitHub Repos. Github Actions Workflow has a robust integration with Microsoft Visual Studio. You can publish solutions using Github Action directly from Visual Studio just by following few steps. If you have your project in a GitHub repository and want to deploy the Azure solution, You can enable the CI/CD using the GitHub Actions workflow. Once the workflow is configured, Push it triggers and CI/CD for the targeted environments executed automatically with all Code. This post lets us learn how we can publish a solution directly from Visual Studio using Github Actions.

CI/CD using GitHub Actions Workflow

Firstly, ensure you have ensured the Preview Feature for “GitHub Action Support in Publish” is enabled. The Preview Features Page is available under Tools Options Environment > Preview Features.

Enable GitHub Actions Support in Publish
Enable the Preview Features

Read More : Don’t See the Preview Features in Visual Studio – Try This

Once this feature is enabled, From the Visual Studio, open the solution from GitHub for the deployment. Right Click on Solution and Click on Publish

Click on Publish
Click on Publish for deploying the solution from Visual Studio

With that, Publish Option will bring the Publish Wizard for Visual Studio, Where we need to select for Target Environment, Platform Services, Resources, and Other Options.

Publish Wizard - Select Target
Publish Wizard – Select Target

Let us choose the “Azure” as the target environment and select one Azure App Service for the Deployment. You can create an App Service directly from this Tooling Support or create one from Azure Portal and Map it here.

Publish Wizard - Select App Services for Deployment
Publish Wizard – Select App Services for Deployment

Once the Target and App Service is selected, moved to the “Deployment Type.” In this section, you must ensure to select “CI/CD using GitHub Actions Workflows.” This takes care of Integrating Publishing with GitHub Action and Generates the yml for build and deployment.

CI/CD using GitHub Actions workflows
CI/CD using GitHub Actions workflows

Finally, Click on Finish. It’s done. Visual Studio will take care of the rest of the thing. It will create all the necessary files for GitHub Action, for Build and Release. If you open your GitHub Repository and Move to the Action Tab, you will find the Build details and execution steps.

GitHub Action Build
GitHub Action Build

Moreover, after Workflow is completed successfully, Visual Studio Publish Wizard displays the status of the Workflow. In Addition, from this screen, you can select “Show Commit details” which will take you to the GitHub Action Tab.

GitHub Action Workflow Successful
GitHub Action Workflow Successful

View All Workflows

Finally, To view all the workflows, navigate to your GitHub Repository and move to Actions Tab. It will display all run workflow. After that, you can select each of them and dig dive to see what has been executed.

List of All Workflow from GitHub Actions
List of All Workflow from GitHub Actions

To Summarize, CI/CD using GitHub Actions can be easily established directly from Visual Studio by following few steps.

  • Firstly, Ensure to have the “GitHub Actions Support in Publish” is enabled.
  • Secondly, Open the Solution from GitHub Repository and Select Publish
  • Thirdly, From the Publish Wizard, select Target and Deployment Services
  • Finally, Choose Deployment Types as “CI/CD using GitHub Actions Workflows.

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.