-
Notifications
You must be signed in to change notification settings - Fork 14
self-hosted runner: always use latest Git for Windows and GitHub Actions version (plus some PowerShell cleanups) #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@dscho forget to req review on this one but when you have the time, take a look at it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wonderful!
I would like to wait for @dennisameling's review before merging this because they are much more familiar with this stuff than I am (I basically only cargo-culted my work on this so far).
Apart from the one change to a [bool]
(which I am not so sure about), I only have two minor suggestions (but I won't insist on them): in the Git project, we usually craft commit messages with a lot more information. Oh, and every time I read "GitHub" with a lower-case "h" my brain mis-pronounces that word; PowerShell might be case-insensitive, but I am not 😁
Write-Output "Installing GitHub Actions runner ${GitHubActionsRunnerVersion} as a Windows service with labels ${GithubActionsRunnerLabels}..." | ||
if ((Get-FileHash -Path $GitHubAction.OutFile -Algorithm SHA256).Hash.ToUpper() -ne $GitHubAction.hash) { throw 'Computed checksum did not match' } | ||
|
||
Write-Output "Installing GitHub Actions runner $($GitHubAction.Tag) as a Windows service with labels $($GitHubAction.RunnerLabels)..." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really interesting information. Since the post-deployment script is run on Azure, and the GitHub workflow that kicks off that deployment has no connection to the actual deployment, I wonder whether there is any way we could manually mirror it into the GitHub workflow run's logs... @dennisameling any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, ooh, I think I found something: https://learn.microsoft.com/en-us/powershell/module/az.resources/get-azdeploymentscriptlog?view=azps-9.3.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean? Do you want to log information from the script? If so, that's possible. I can even make somethign that can send you a email if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, ooh, I think I found something: https://learn.microsoft.com/en-us/powershell/module/az.resources/get-azdeploymentscriptlog?view=azps-9.3.0
Nice try, but Deployment Scripts are something else than the Custom Script Extension 😉
Let's follow up in this PR for getting the post-deployment script output 👍🏼
Reverted Parameter StopService to string from boolen. Changed -notlike to -like in the parameter validation of GitHubActionRunnerRegistrationUrl
Reverted StopService parameter back to string from bool and adjusted the changes in the rest of the code. Fixed parameter GitHubActionsRunnerRegistrationUrl so it's -like and not -notlike in the validation.
Missed to add validation on StartService parameter when I did revert it back from bool, It's fixed now.
@dscho i know I need to train on my comments on the commits. Same at work. I added some better ones for mistakes I was correcting I wanted to use switch instead of bool but as I don't know how you execute the script I don't know if switch was good to use or not. String for true or false is a big no ;) but I did revert it back I'll adjust the script a little more during the end of next week I have some more adjustments that I want to add to make it even better. Sorry that my last commits was unsigned I did not have any pgp cert for GitKraken but now I have fixed that too, thought it would use my ssl cert that vs and vscode are using. |
Oh, you don't need to bother with GPG-signing... I was thinking more about giving context in the commit messages, intentions and additional information that's not obvious from reading the diff. About using |
We use Microsoft's Azure Custom Script Extension for it. Here's how it's invoked. So I guess that something like this happens behind the scenes:
I'll test your changes on a fresh VM later today :) thanks for your work on this! |
I did return it to string but as it look of it I can improve it more now when I know how you execute it. But test this things out first and after that I during next week improve it more :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just ran the script on a fresh VM. Everything looks great. Also really like how you approached this in PowerShell. Thanks @rstolpe! 🚀
Script log
Starting post-deployment script. Enabling Windows Developer Mode... Enabled Windows developer mode. Adding Microsoft Defender Exclusions... Finished adding Microsoft Defender Exclusions. Downloading Git for Windows... Installing Git for Windows... Finished installing Git for Windows. Downloading GitHub Actions runner... Installing GitHub Actions runner 2.300.2 as a Windows service with labels self-hosted,Windows,ARM64... Configuring the runner to shut down automatically after running Configuring the runner -------------------------------------------------------------------------------- | ____ _ _ _ _ _ _ _ _ | | / ___(_) |_| | | |_ _| |__ / \ ___| |_(_) ___ _ __ ___ | | | | _| | __| |_| | | | | '_ \ / _ \ / __| __| |/ _ \| '_ \/ __| | | | |_| | | |_| _ | |_| | |_) | / ___ \ (__| |_| | (_) | | | \__ \ | | \____|_|\__|_| |_|\__,_|_.__/ /_/ \_\___|\__|_|\___/|_| |_|___/ | | | | Self-hosted runner registration | | | -------------------------------------------------------------------------------- # Authentication √ Connected to GitHub # Runner Registration √ Runner successfully added √ Runner connection is good # Runner settings √ Settings Saved. Granting file permissions to 'NT AUTHORITY\NETWORK SERVICE'. Service actions.runner.dennisameling-git-for-windows-automation.arm64-test-vm-dennis successfully installed Service actions.runner.dennisameling-git-for-windows-automation.arm64-test-vm-dennis successfully set recovery option Service actions.runner.dennisameling-git-for-windows-automation.arm64-test-vm-dennis successfully set to delayed auto start Service actions.runner.dennisameling-git-for-windows-automation.arm64-test-vm-dennis successfully configured Waiting for service to start... Service actions.runner.dennisameling-git-for-windows-automation.arm64-test-vm-dennis started successfully Finished installing GitHub Actions runner.
@dennisameling ill optimize it some more at the end of next week but until that I do think this will work for you. It's nice to contribute to other projects. Just DM me if you have some other things you want automated or similar :) |
@dscho could you do a final review? I guess you'll want some more descriptive commit messages, right? |
Maybe next time the commit messages could follow the Intent, Context, Implementation & Justification format. But I don't want to hold up this contribution any further 😄 |
GitHub git-windows and Action runner
Ensure that Action runner service was created
Added so it will look if it has been created 3 times 3 seconds apart before it write error as sometime it can take time for the service to be created.
Stop Service, actions.runner.*
Param
Error handling
Other
Got some more things that I can do later on when I have the time, I have tested it locally at the code should work but as I can't test with ActionRunner I'm advising you to test it also.