09 Feb 2022

GitHub action Journey – Part 1

Mobile No Comments

I have a project and I’m working to setup CI CD on a server – and I want to use github actions.

This is for a dev environment, of course.

However – my project uses Entity Framework with MqSql. Web Deploy with DB updates and migrations – I can see a problem here.

So – My goal is to setup a powershell scripts that post build will copy my migration utility to the server, then run that on the database.

First, I needed SSL certs. Enter Posh-ACME! Excellent tool for using free wildcard certs.

You can find it here:

Next, was the remote powershell. I won’t go into the details on setting up listeners – but here’s a great getting started post about it.

However, if you have an SSL certificate already, you don’t need to use a self signed certificate as mentioned in the blog. Instead…

You can use one of your free certificates like this:

First, get all the certificates via powershell like this:

Get-ChildItem Cert:\Localmachine\My

Then, you can use the fingerprint to tell your HTTPS listener to use is like this:

$cert = Get-ChildItem -Path cert:\Localmachine\My\<the thumbprint for your ssl cert>
New-Item -Path WSMan:\Localhost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force

Since the cert can be verified – from your remote machine that you’ve allowed through your firewall, you can now script remote powershell commands.

So my postbuild script will get my migration build on the server, then remote in, stop the site, run migrations, and restart the site.

No Responses to “GitHub action Journey – Part 1”

Leave a Reply

Currently you have JavaScript disabled. In order to post comments, please make sure JavaScript and Cookies are enabled, and reload the page. Click here for instructions on how to enable JavaScript in your browser.