DEV Community

Cover image for No YAML Needed! Create GitHub Actions Workflows from VS and CLI
Davide 'CoderDave' Benvegnù
Davide 'CoderDave' Benvegnù

Posted on

No YAML Needed! Create GitHub Actions Workflows from VS and CLI

Today I'm going to show you two very easy ways to create your GitHub Actions CI Workflow for .NET Applications, without writing a single line of YAML.

Intro

Getting started with GitHub Actions may not be always easy. Especially when the alternatives for deployment are so easy (like the right-click publish in Visual Studio, for example). What if we could create our CI workflows with Actions in the same way?

Btw, I'd be curious to know how you create your GitHub Actions workflow. Let me know in the comment section below if you do it directly in the GitHub UI, or in VSCode perhaps with some extension, or however else you do it.

Video

As usual, if you are a visual learner, or simply prefer to watch and listen instead of reading, here you have the video with the whole explanation and demo, which to be fair is much more complete than this post.

Link to the video: https://youtu.be/N2ELIqLWz0k

If you rather prefer reading, well... let's just continue :)

The Tools

The first tool we are going to take a look at is integrated in Visual Studio, so it works on Windows, while the second one requires the use of the CLI and therefore can be used in MacOS and Linux as well.

Let's jump into VS.

From Visual Studio

Doing it from Visual Studio is pretty straight forward.

Deployment Type

Just right-click on the Project Name, select __Publish, choose your deployment target, and then you have the new _Deployment Type_ selection.

You can either deploy directly, as usual, or create a YAML file for the GitHub Actions CI/CD.

After confirmation, Visual Studio will take care of the rest and create the YAML file for you in the .github/workflows folder, named as your deployment target.

YAML Generated

As you can see in the image, the workflow takes care of both CI and CD for your application

If you are on Visual Studio 2019 and you don't see the deployment type selection, make sure the feature is enabled. Go to Tools > Options > Environment > Preview Features and make sure the GitHub Actions support in Publish is checked.

From The CLI

As I've said, the second way I have for you to generate a GitHub Actions Workflow without writing the YAML is using the dotnet CLI.

Tim Heuer has in fact created an awesome template that generates the workflow files for GitHub Actions from the CLI.

First thing, we need to install the template:

dotnet new -i TimHeuer.GitHubActions.Templates
Enter fullscreen mode Exit fullscreen mode

This will add the feature we want to use. Then just execute

dotnet new workflow
Enter fullscreen mode Exit fullscreen mode

in the root folder of your project and you are done.

What you’ll get is a straightforward GitHub Actions workflow to build and test your .NET application. Keep in mind this is a starting point. It’s not going to do everything you might want, but it’s a solid base to build from.

Conclusions

Cool right? Let me know down below what you think about this, and as I've said before also how you usually create your Actions workflows.

Also, speaking of GitHub Actions, checkout this video, where I talk about creating and using templates.

Like, share and follow me 🚀 for more content:

📽 YouTube
Buy me a coffee
💖 Patreon
📧 Newsletter
🌐 CoderDave.io Website
👕 Merch
👦🏻 Facebook page
🐱‍💻 GitHub
👲🏻 Twitter
👴🏻 LinkedIn
🔉 Podcast

Buy Me A Coffee

Top comments (0)