Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1092015%22%20slang%3D%22en-US%22%3EHow%20to%20use%20GitHub%20Actions%20to%20deploy%20an%20Azure%20Virtual%20Machine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1092015%22%20slang%3D%22en-US%22%3E%3CP%3EHands%20up%20if%20you%20are%20used%20to%20deploy%20servers%20either%20by%20unpacking%20them%20from%20a%20box%20or%20using%20a%20graphical%20user%20interface%20(GUI)%3F%20Yip%2C%20that%E2%80%99s%20me%20and%20it's%20where%20I%E2%80%99ve%20built%20my%20career.%26nbsp%3B%20However%2C%20over%20the%20last%20few%20years%20I%E2%80%99ve%20been%20getting%20more%20and%20more%20used%20to%20deploying%20servers%20and%20their%20supporting%20resources%20via%20code.%26nbsp%3B%20Either%20using%20something%20like%20PowerShell%20or%20Azure%20CLI%2C%20or%20sometimes%20a%20combination%20of%20both.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%E2%80%99ve%20also%20taught%20myself%20how%20to%20use%20tools%20such%20as%20Visual%20Studio%20Code%2C%20Git%2C%20GitHub%20or%20even%20Azure%20DevOps%20to%20get%20the%20task%20done.%20%26nbsp%3BIt%E2%80%99s%20not%20been%20an%20easy%20journey%20but%20what%20it%20has%20been%20is%20fun%20and%20a%20challenge.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20the%20end%20of%202019%20GitHub%20announced%20%3CA%20href%3D%22https%3A%2F%2Fgithub.blog%2F2019-11-14-powering-community-led-innovation-with-github-actions%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20Actions%3C%2FA%3E%2C%20a%20new%20way%20to%20automate%20deployment%20of%20code%20from%20GitHub%20repositories.%20%26nbsp%3BI%E2%80%99ve%20been%20watching%20with%20interest%20as%20my%20developer%20focused%20colleagues%20and%20friends%20dig%20into%20the%20new%20service%20and%20show%20examples%20of%20it%20being%20used%20and%20have%20decided%20to%20take%20a%20look%20at%20it%20myself%20and%20see%20what%20it%20can%20do%20for%20the%20IT%20Pro%20community%2C%20as%20I%E2%80%99m%20a%20firm%20believer%20that%20these%20types%20of%20tools%20can%20offer%20IT%20Pros%20great%20opportunities%20as%20well.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--735659649%22%20id%3D%22toc-hId--735659649%22%20id%3D%22toc-hId--735659649%22%3E%3CSTRONG%3EGitHub%20Actions%20Terminology%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20is%20some%20new%20terminology%20that%20comes%20with%20GitHub%20Actions%2C%20so%20let%E2%80%99s%20define%20those%20before%20we%20dig%20in.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EAction%3C%2FSTRONG%3E%20%E2%80%93%20these%20define%20what%20we%20can%20do%2C%20we%20can%20either%20get%20them%20from%20the%20marketplace%20(free)%20or%20build%20our%20own%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EWorkflow%3C%2FSTRONG%3E%20%E2%80%93%20A%20collection%20of%20Environment%20variables%2C%20Jobs%20and%20Steps%20that%20are%20completed%20when%20an%20event%20happens%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EJobs%3C%2FSTRONG%3E%20%E2%80%93%20What%20the%20workflow%20will%20do%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESteps%3C%2FSTRONG%3E%20-%20A%20task%20undertaken%20by%20a%20Job%20using%20an%20Action%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EEvent%3C%2FSTRONG%3E%20%E2%80%93%20Something%20that%20happens%20and%20triggers%20a%20workflow%2C%20e.g%20a%20commit%20is%20pushed%20to%20a%20repository%2C%20an%20issue%20or%20pull%20request%20is%20issued%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH4%20id%3D%22toc-hId-1751853184%22%20id%3D%22toc-hId-1751853184%22%20id%3D%22toc-hId-1751853184%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22toc-hId--55601279%22%20id%3D%22toc-hId--55601279%22%20id%3D%22toc-hId--55601279%22%3E%3CSTRONG%3EWhat%20do%20you%20want%20to%20build%3F%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3EKeeping%20it%20simple%2C%20I%20want%20my%20GitHub%20Action%20to%20build%20a%20virtual%20machine%20(VM)%20within%20Azure.%26nbsp%3B%20Keeping%20it%20really%20simple%20I%20want%20it%20to%20build%20the%20VM%20and%20it%E2%80%99s%20associated%20supporting%20technology%20(disk%2C%20network%20interface%2C%20virtual%20network%2C%20storage%20account%2C%20etc)%20within%20the%20same%20resource%20group.%20%26nbsp%3BThis%20isn%E2%80%99t%20exactly%20best%20practice%20but%20is%20an%20easy%20example%20to%20start%20with%20and%20one%20that%20is%20well%20known%2Fdocumented.%3C%2FP%3E%0A%3CP%3EI%20can%20use%20four%20blocks%20of%20Azure%20CLI%20code%20to%20build%20the%20VM%20within%20Azure.%20%26nbsp%3BThe%20first%20block%20of%20code%20helps%20log%20into%20my%20Azure%20subscription%20using%20an%20Azure%20Service%20Principal%20and%20perform%20the%20necessary%20steps%20to%20create%20the%20VM.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23region%20Login%0A%23%20This%20logs%20into%20Azure%20with%20a%20Service%20Principal%20Account%0A%23%0AWrite-Output%20%22Logging%20in%20to%20Azure%20with%20a%20service%20principal...%22%0Aaz%20login%20%60%0A%20%20%20%20--service-principal%20%60%0A%20%20%20%20--username%20%24servicePrincipal%20%60%0A%20%20%20%20--password%20%24servicePrincipalSecret%20%60%0A%20%20%20%20--tenant%20%24servicePrincipalTenantId%0AWrite-Output%20%22Done%22%0AWrite-Output%20%22%22%0A%23endregion%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20next%20section%20selects%20the%20correct%20subscription%2C%20just%20to%20be%20sure%20my%20resources%20go%20to%20the%20right%20place%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23region%20Subscription%0A%23This%20sets%20the%20subscription%20the%20resources%20will%20be%20created%20in%0AWrite-Output%20%22Setting%20default%20azure%20subscription...%22%0Aaz%20account%20set%20%60%0A%20%20%20%20--subscription%20%24azureSubscriptionName%0AWrite-Output%20%22Done%22%0AWrite-Output%20%22%22%0A%23endregion%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20third%20section%20creates%20the%20resource%20group%20for%20my%20VM%20to%20live%20in%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23region%20Create%20Resource%20Group%0A%23%20This%20creates%20the%20resource%20group%20used%20to%20house%20the%20VM%0AWrite-Output%20%22Creating%20resource%20group%20%24resourceGroupName%20in%20region%20%24resourceGroupNameRegion...%22%0Aaz%20group%20create%20%60%0A%20%20%20%20--name%20%24resourceGroupName%20%60%0A%20%20%20%20--location%20%24resourceGroupNameRegion%0A%20%20%20%20Write-Output%20%22Done%20creating%20resource%20group%22%0A%20%20%20%20Write-Output%20%22%22%0A%23endregion%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20the%20fourth%20section%20creates%20the%20VM%20within%20that%20resource%20group%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%23region%20Create%20VM%0A%23%20Create%20a%20VM%20in%20the%20resource%20group%0AWrite-Output%20%22Creating%20VM...%22%0Atry%20%7B%0A%20%20%20%20az%20vm%20create%20%20%60%0A%20%20%20%20%20%20%20%20--resource-group%20%24resourceGroupName%20%60%0A%20%20%20%20%20%20%20%20--name%20%24serverName%20%60%0A%20%20%20%20%20%20%20%20--image%20win2016datacenter%20%60%0A%20%20%20%20%20%20%20%20--admin-username%20%24adminLogin%20%60%0A%20%20%20%20%20%20%20%20--admin-password%20%24adminPassword%0A%20%20%20%20%7D%0Acatch%20%7B%0A%20%20%20%20Write-Output%20%22VM%20already%20exists%22%0A%20%20%20%20%7D%0AWrite-Output%20%22Done%20creating%20VM%22%0AWrite-Output%20%22%22%0A%23endregion%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26gt%3B%3C%2FP%3E%0A%3CP%3EThe%20code%20isn%E2%80%99t%20complex%20and%20is%20a%20well-known%20example%20you%20can%20see%20in%20a%20lot%20of%20Documentation%20and%20tutorials.%20Within%20my%20script%20I%E2%80%99ve%20used%20various%20parameters%20to%20allow%20me%20to%20store%20the%20information%20securely%20or%20pass%20it%20in%20from%20my%20workflow%20file.%20%26nbsp%3BYou%20can%20find%20my%20full%20PowerShell%20script%20%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Fweeyin83%2F81e7a7bf3caf3d0bce787db5d562b47e%3FWT.mc_id%3Dblog-itops-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1863055742%22%20id%3D%22toc-hId--1863055742%22%20id%3D%22toc-hId--1863055742%22%3E%3CSTRONG%3EHow%20do%20I%20instruct%20the%20Action%3F%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3ETo%20kick%20off%20the%20VM%20build%20we%20construct%20a%20Workflow%20file.%26nbsp%3B%20This%20is%20in%20the%20form%20of%20YAML.%26nbsp%3B%20You%20can%20call%20your%20workflow%20file%20anything%20you%20want%20as%20long%20as%20it%20ends%20with.%20yml%20or%20.yaml%20as%20the%20extension%20type.%20It%20also%20needs%20to%20be%20stored%20within%20a%20specific%20directory%20within%20your%20GitHub%20repository%20-%20%3CSTRONG%3E.github%2Fworkflows%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EYour%20workflow%20file%20is%20split%20up%20into%20several%20sections%2C%20let%E2%80%99s%20look%20at%20each%20of%20them%20individually%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EMetadata%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20start%20off%20with%20some%20naming%20the%20workflow%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Ename%3A%20GitHub%20for%20IT%20Pro%20CI%2FCD%20Pipeline%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EEnvironment%20variables%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EEnv%3A%0A%0A%20%20OUTPUT_PATH%3A%20%24%7B%7B%20github.workspace%20%7D%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETriggers%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWe%20then%20instruct%20how%20the%20action%20will%20be%20%3CA%20href%3D%22https%3A%2F%2Fhelp.github.com%2Fen%2Factions%2Fautomating-your-workflow-with-github-actions%2Fworkflow-syntax-for-github-actions%23on%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Etriggered%3C%2FA%3E%3B%20I%20have%20set%20my%20action%20to%20start%20whenever%20something%20is%20pushed%20to%20the%20repository%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Eon%3A%20%5Bpush%5D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EJobs%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ENow%20we%20start%20to%20declare%20the%20jobs%20that%20our%20workflow%20will%20do%2C%20we%20have%20to%20start%20by%20declaring%20what%20platform%20our%20Workflow%20will%20run%20on%20(Linux%2C%20MacOS%20or%20Windows).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Ejobs%3A%0A%0A%23%20Deploy%20VM%20in%20Azure%0A%0A%20%20DeployVM%3A%0A%0A%20%20%20%20runs-on%3A%20windows-latest%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESteps%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20we%20can%20start%20with%20the%20steps%20within%20the%20workflow.%26nbsp%3B%20The%20first%20step%20I%E2%80%99ve%20instructed%20my%20workflow%20to%20do%20a%20checkout.%26nbsp%3B%20This%20takes%20the%20files%2Fcode%20from%20my%20repository%20and%20puts%20it%20into%20%3CSTRONG%3E%24github.workspace%3C%2FSTRONG%3E%20for%20my%20workflow%20to%20access%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Esteps%3A%0A%0A%20%20%20%20%23%20checkout%20code%20from%20repo%0A%0A%20%20%20%20-%20name%3A%20checkout%20repo%0A%0A%20%20%20%20%20%20uses%3A%20actions%2Fcheckout%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20next%20step%20we%20have%20is%20one%20where%20we%20tell%20the%20workflow%20to%20look%20for%20the%20PowerShell%20script%20that%20helps%20to%20build%20the%20VM%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20-%20name%3A%20look%20for%20ps1%20file%0A%0A%20%20%20%20%20%20run%3A%20%7C%0A%0A%20%20%20%20%20%20%20%20ls%20'%24%7B%7B%20env.OUTPUT_PATH%20%7D%7D%5CIaC%5CAzCLI'%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20the%20last%20step%20in%20our%20workflow%20is%20to%20deploy%20and%20provision%20the%20VM%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20-%20name%3A%20provision%20virtual%20machine%20in%20azure%0A%0A%20%20%20%20%20%20env%3A%0A%0A%20%20%20%20%20%20%20%20RESOURCE_GROUP%3A%20rg-githubitpro%0A%0A%20%20%20%20%20%20%20%20RESOURCE_GROUP_REGION%3A%20southcentralus%0A%0A%20%20%20%20%20%20%20%20SERVER_NAME%3A%20gihtubactions%0A%0A%20%20%20%20%20%20%20%20ADMIN_LOGIN%3A%20sarah%0A%0A%20%20%20%20%20%20run%3A%20%26gt%3B%0A%0A%20%20%20%20%20%20%20%20powershell%20-command%20%22%26amp%3B%20'%24%7B%7B%20env.OUTPUT_PATH%20%7D%7D%5CIaC%5CAzCLI%5Cvmcreation.ps1'%22%0A%0A%20%20%20%20%20%20%20%20-servicePrincipal%20%24%7B%7B%20secrets.SERVICE_PRINCIPAL_APPID%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-servicePrincipalSecret%20%24%7B%7B%20secrets.SERVICE_PRINCIPAL_SECRET%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-servicePrincipalTenantId%20%24%7B%7B%20secrets.SERVICE_PRINCIPAL_TENANTID%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-azureSubscriptionName%20%24%7B%7B%20secrets.AZURE_SUBSCRIPTION_ID%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-resourceGroupName%20%25RESOURCE_GROUP%25%0A%0A%20%20%20%20%20%20%20%20-resourceGroupNameRegion%20%25RESOURCE_GROUP_REGION%25%0A%0A%20%20%20%20%20%20%20%20-serverName%20%25SERVER_NAME%25%0A%0A%20%20%20%20%20%20%20%20-adminLogin%20%25ADMIN_LOGIN%25%0A%0A%20%20%20%20%20%20%20%20-adminPassword%20%24%7B%7B%20secrets.ADMIN_PASSWORD%20%7D%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20there%20is%20a%20lot%20to%20that%20step%20so%20let%E2%80%99s%20break%20down%20what%20we%20are%20doing%20even%20further%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20-%20name%3A%20provision%20virtual%20machine%20in%20azure%0A%0A%20%20%20%20%20%20env%3A%0A%0A%20%20%20%20%20%20%20%20RESOURCE_GROUP%3A%20rg-githubitpro%0A%0A%20%20%20%20%20%20%20%20RESOURCE_GROUP_REGION%3A%20southcentralus%0A%0A%20%20%20%20%20%20%20%20SERVER_NAME%3A%20gihtubactions%0A%0A%20%20%20%20%20%20%20%20ADMIN_LOGIN%3A%20sarah%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20first%20part%20is%20declaring%20some%20environment%20variables%2C%20here%20I%20am%20setting%20my%20Azure%20Resource%20Group%20name%2C%20the%20region%20I%20want%20the%20resource%20group%20to%20be%20deployed%20in%2C%20the%20name%20of%20my%20virtual%20machine%20(server)%20and%20the%20name%20of%20the%20admin%20login%20account%20that%20will%20be%20created%20for%20that%20VM.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20second%20stage%20of%20the%20step%20is%20telling%20my%20workflow%20to%20call%20my%20PowerShell%20script%20and%20pass%20in%20the%20following%20variables%20from%20the%20workflow%20and%20%3CA%20href%3D%22https%3A%2F%2Fhelp.github.com%2Fen%2Factions%2Fautomating-your-workflow-with-github-actions%2Fcreating-and-using-encrypted-secrets%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20Secrets%20store%3C%2FA%3E.%20%26nbsp%3BTo%20allow%20GitHub%20Actions%20to%20deploy%20resources%20within%20my%20Azure%20Subscription%20I%20have%20created%20an%20Azure%20Service%20Principal.%26nbsp%3B%20If%20you%E2%80%99ve%20never%20worked%20within%20them%20before%20I%20wrote%20an%20article%20covering%20how%20to%20create%20and%20work%20with%20them%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fitops-talk-blog%2Fworking-with-azure-service-principal-accounts%2Fba-p%2F1086961%3FWT.mc_id%3Dblog-itopstalk-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Erun%3A%20%26gt%3B%0A%0A%20%20%20%20%20%20%20%20powershell%20-command%20%22%26amp%3B%20'%24%7B%7B%20env.OUTPUT_PATH%20%7D%7D%5CIaC%5CAzCLI%5Cvmcreation.ps1'%22%0A%0A%20%20%20%20%20%20%20%20-servicePrincipal%20%24%7B%7B%20secrets.SERVICE_PRINCIPAL_APPID%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-servicePrincipalSecret%20%24%7B%7B%20secrets.SERVICE_PRINCIPAL_SECRET%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-servicePrincipalTenantId%20%24%7B%7B%20secrets.SERVICE_PRINCIPAL_TENANTID%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-azureSubscriptionName%20%24%7B%7B%20secrets.AZURE_SUBSCRIPTION_ID%20%7D%7D%0A%0A%20%20%20%20%20%20%20%20-resourceGroupName%20%25RESOURCE_GROUP%25%0A%0A%20%20%20%20%20%20%20%20-resourceGroupNameRegion%20%25RESOURCE_GROUP_REGION%25%0A%0A%20%20%20%20%20%20%20%20-serverName%20%25SERVER_NAME%25%0A%0A%20%20%20%20%20%20%20%20-adminLogin%20%25ADMIN_LOGIN%25%0A%0A%20%20%20%20%20%20%20%20-adminPassword%20%24%7B%7B%20secrets.ADMIN_PASSWORD%20%7D%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20a%20full%20copy%20of%20this%20workflow%20file%2C%20you%20can%20find%20it%20%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Fweeyin83%2Fb63d320cc814dee9aebb599b847d0a49%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-624457091%22%20id%3D%22toc-hId-624457091%22%20id%3D%22toc-hId-624457091%22%3E%3CSTRONG%3EMonitoring%20the%20GitHub%20Action%20running%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3EWhen%20the%20Action%20is%20running%20you%20can%20monitor%20its%20progress.%20When%20you%20navigate%20to%20your%20repository%20on%20the%20GitHub%20website%20you%20will%20see%20a%20tab%20called%20Actions%2C%20click%20into%20that%20will%20take%20you%20into%20the%20Workflow%20section.%26nbsp%3B%20You%20can%20create%20new%20workflows%2C%20edit%20workflows%20and%20monitor%20the%20progress%20of%20the%20workflows%20running.%3C%2FP%3E%0A%3CCENTER%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163886i433300750608D8F9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22vmactions.JPG%22%20title%3D%22vmactions.JPG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20Actions%20Tab%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCENTER%3E%0A%3CP%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163889iD61736851B0DA262%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22vmactionmonitor.JPG%22%20title%3D%22vmactionmonitor.JPG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EMonitoring%20GitHub%20Actions%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20once%20the%20workflow%20has%20completed%20you%20can%20check%20in%20your%20Azure%20subscription%20and%20hopefully%20see%20the%20resource%20created%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CCENTER%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163887i4528F2147C235951%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22vmactionresult.JPG%22%20title%3D%22vmactionresult.JPG%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EAzure%20Resources%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FCENTER%3E%0A%3CH4%20id%3D%22toc-hId--1182997372%22%20id%3D%22toc-hId--1182997372%22%20id%3D%22toc-hId--1182997372%22%3E%26nbsp%3B%3C%2FH4%3E%0A%3CH4%20id%3D%22toc-hId-1304515461%22%20id%3D%22toc-hId-1304515461%22%20id%3D%22toc-hId-1304515461%22%3E%3CSTRONG%3EThings%20to%20think%20about%3C%2FSTRONG%3E%3C%2FH4%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMy%20example%20workflow%20is%20a%20very%20basic%20one%20and%20the%20resource%20that%20I%20am%20deploying%20is%20a%20very%20basic%20one%2C%20however%20for%20me%20it%20was%20a%20great%20starting%20point%20to%20learn%20GitHub%20Actions.%26nbsp%3B%20I%E2%80%99ve%20seen%20my%20colleagues%20use%20it%20for%20much%20more%20complex%20deployments%20and%20workflows%2C%20for%20example%20Aaron%20Powell%20is%20using%20it%20to%20%3CA%20href%3D%22https%3A%2F%2Fwww.aaron-powell.com%2Fposts%2F2019-12-17-implementing-github-actions-for-my-blog%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edeploy%20his%20blog%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fweeyin83%2Fvm-actions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erepository%3C%2FA%3E%20I%20created%20to%20test%20out%20this%20deployment%20is%20a%20public%20one%20and%20the%20output%20of%20my%20workflow%20is%20available%20for%20anyone%20logged%20in%20or%20not%20to%20GitHub%20to%20view%2C%20which%20displays%20certain%20information%20that%20could%20be%20considered%20as%20sensitive%20such%20as%20my%20Azure%20Subscription%20ID%20and%20more%20importantly%20the%20Public%20IP%20address%20of%20my%20VM%2C%20which%20gives%20people%20with%20bad%20intentions%20an%20easy%20attack%20surface.%20%26nbsp%3BSo%2C%20if%20you%20are%20testing%20GitHub%20Actions%20please%20be%20aware%20of%20this%20and%20vigilant%20on%20what%20you%20deploy%20in%20Azure%20and%20how%20it%20is%20secured.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI've%20recorded%20a%20video%20of%20me%20walking%20through%20the%20code%20and%20each%20step%2C%20this%20video%20can%20be%20found%20here%3A%26nbsp%3B%3C%2FP%3E%0A%3CCENTER%3E%3CIFRAME%20src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2F0kDr9OlAzlM%22%20width%3D%22560%22%20height%3D%22315%22%20frameborder%3D%220%22%20allowfullscreen%3D%22allowfullscreen%22%20allow%3D%22accelerometer%3B%20autoplay%3B%20encrypted-media%3B%20gyroscope%3B%20picture-in-picture%22%3E%3C%2FIFRAME%3E%3C%2FCENTER%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%E2%80%99d%20love%20to%20hear%20how%20other%20IT%20Pros%20are%20using%20GitHub%20Actions%20to%20deploy%20infrastructure%2C%20so%20please%20do%20reach%20out%20and%20share%20your%20stories!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1092015%22%20slang%3D%22en-US%22%3E%3CP%3EAt%20the%20end%20of%202019%20GitHub%20announced%20GitHub%20Actions%2C%20which%20is%20a%20way%20of%20automating%20code%20deployment%2C%20I've%20been%20investigating%20how%20you%20can%20use%20it%20to%20deploy%20infrastructure%20resources%20within%20Azure.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F163891i3FE3CECEAA8D744A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22githubactions.png%22%20title%3D%22githubactions.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EGitHub%20Actions%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1092015%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESarah%20Lean%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1126738%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20GitHub%20Actions%20to%20deploy%20an%20Azure%20Virtual%20Machine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1126738%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20for%20Sharing%20with%20the%20community%26nbsp%3B%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Fcool_40x40.gif%22%20alt%3D%22%3Acool%3A%22%20title%3D%22%3Acool%3A%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

Hands up if you are used to deploy servers either by unpacking them from a box or using a graphical user interface (GUI)? Yip, that’s me and it's where I’ve built my career.  However, over the last few years I’ve been getting more and more used to deploying servers and their supporting resources via code.  Either using something like PowerShell or Azure CLI, or sometimes a combination of both.

 

I’ve also taught myself how to use tools such as Visual Studio Code, Git, GitHub or even Azure DevOps to get the task done.  It’s not been an easy journey but what it has been is fun and a challenge.

 

At the end of 2019 GitHub announced GitHub Actions, a new way to automate deployment of code from GitHub repositories.  I’ve been watching with interest as my developer focused colleagues and friends dig into the new service and show examples of it being used and have decided to take a look at it myself and see what it can do for the IT Pro community, as I’m a firm believer that these types of tools can offer IT Pros great opportunities as well.

 

GitHub Actions Terminology

 

There is some new terminology that comes with GitHub Actions, so let’s define those before we dig in.

  • Action – these define what we can do, we can either get them from the marketplace (free) or build our own
  • Workflow – A collection of Environment variables, Jobs and Steps that are completed when an event happens
  • Jobs – What the workflow will do
  • Steps - A task undertaken by a Job using an Action
  • Event – Something that happens and triggers a workflow, e.g a commit is pushed to a repository, an issue or pull request is issued

 

What do you want to build?

Keeping it simple, I want my GitHub Action to build a virtual machine (VM) within Azure.  Keeping it really simple I want it to build the VM and it’s associated supporting technology (disk, network interface, virtual network, storage account, etc) within the same resource group.  This isn’t exactly best practice but is an easy example to start with and one that is well known/documented.

I can use four blocks of Azure CLI code to build the VM within Azure.  The first block of code helps log into my Azure subscription using an Azure Service Principal and perform the necessary steps to create the VM.

 

 

 

#region Login
# This logs into Azure with a Service Principal Account
#
Write-Output "Logging in to Azure with a service principal..."
az login `
    --service-principal `
    --username $servicePrincipal `
    --password $servicePrincipalSecret `
    --tenant $servicePrincipalTenantId
Write-Output "Done"
Write-Output ""
#endregion

 

 

 

The next section selects the correct subscription, just to be sure my resources go to the right place:

 

 

 

#region Subscription
#This sets the subscription the resources will be created in
Write-Output "Setting default azure subscription..."
az account set `
    --subscription $azureSubscriptionName
Write-Output "Done"
Write-Output ""
#endregion

 

 

 

The third section creates the resource group for my VM to live in:

 

 

 

#region Create Resource Group
# This creates the resource group used to house the VM
Write-Output "Creating resource group $resourceGroupName in region $resourceGroupNameRegion..."
az group create `
    --name $resourceGroupName `
    --location $resourceGroupNameRegion
    Write-Output "Done creating resource group"
    Write-Output ""
#endregion

 

 

 

 

And the fourth section creates the VM within that resource group:

 

 

 

#region Create VM
# Create a VM in the resource group
Write-Output "Creating VM..."
try {
    az vm create  `
        --resource-group $resourceGroupName `
        --name $serverName `
        --image win2016datacenter `
        --admin-username $adminLogin `
        --admin-password $adminPassword
    }
catch {
    Write-Output "VM already exists"
    }
Write-Output "Done creating VM"
Write-Output ""
#endregion

 

 

 

>

The code isn’t complex and is a well-known example you can see in a lot of Documentation and tutorials. Within my script I’ve used various parameters to allow me to store the information securely or pass it in from my workflow file.  You can find my full PowerShell script here.

 

How do I instruct the Action?

To kick off the VM build we construct a Workflow file.  This is in the form of YAML.  You can call your workflow file anything you want as long as it ends with. yml or .yaml as the extension type. It also needs to be stored within a specific directory within your GitHub repository - .github/workflows

Your workflow file is split up into several sections, let’s look at each of them individually:

 

Metadata

 

We start off with some naming the workflow:

 

 

 

name: GitHub for IT Pro CI/CD Pipeline

 

 

 

Environment variables:

 

 

 

Env:

  OUTPUT_PATH: ${{ github.workspace }}

 

 

 

Triggers

We then instruct how the action will be triggered; I have set my action to start whenever something is pushed to the repository:

 

 

 

on: [push]

 

 

 

Jobs

Now we start to declare the jobs that our workflow will do, we have to start by declaring what platform our Workflow will run on (Linux, MacOS or Windows).

 

 

 

jobs:

# Deploy VM in Azure

  DeployVM:

    runs-on: windows-latest

 

 

 

Steps

 

Now we can start with the steps within the workflow.  The first step I’ve instructed my workflow to do a checkout.  This takes the files/code from my repository and puts it into $github.workspace for my workflow to access it.

 

 

 

steps:

    # checkout code from repo

    - name: checkout repo

      uses: actions/checkout

 

 

 

The next step we have is one where we tell the workflow to look for the PowerShell script that helps to build the VM:

 

 

 

    - name: look for ps1 file

      run: |

        ls '${{ env.OUTPUT_PATH }}\IaC\AzCLI'

 

 

 

And the last step in our workflow is to deploy and provision the VM:

 

 

 

 - name: provision virtual machine in azure

      env:

        RESOURCE_GROUP: rg-githubitpro

        RESOURCE_GROUP_REGION: southcentralus

        SERVER_NAME: gihtubactions

        ADMIN_LOGIN: sarah

      run: >

        powershell -command "& '${{ env.OUTPUT_PATH }}\IaC\AzCLI\vmcreation.ps1'"

        -servicePrincipal ${{ secrets.SERVICE_PRINCIPAL_APPID }}

        -servicePrincipalSecret ${{ secrets.SERVICE_PRINCIPAL_SECRET }}

        -servicePrincipalTenantId ${{ secrets.SERVICE_PRINCIPAL_TENANTID }}

        -azureSubscriptionName ${{ secrets.AZURE_SUBSCRIPTION_ID }}

        -resourceGroupName %RESOURCE_GROUP%

        -resourceGroupNameRegion %RESOURCE_GROUP_REGION%

        -serverName %SERVER_NAME%

        -adminLogin %ADMIN_LOGIN%

        -adminPassword ${{ secrets.ADMIN_PASSWORD }}

 

 

 

Now there is a lot to that step so let’s break down what we are doing even further:

 

 

 

    - name: provision virtual machine in azure

      env:

        RESOURCE_GROUP: rg-githubitpro

        RESOURCE_GROUP_REGION: southcentralus

        SERVER_NAME: gihtubactions

        ADMIN_LOGIN: sarah

 

 

 

This first part is declaring some environment variables, here I am setting my Azure Resource Group name, the region I want the resource group to be deployed in, the name of my virtual machine (server) and the name of the admin login account that will be created for that VM.

 

The second stage of the step is telling my workflow to call my PowerShell script and pass in the following variables from the workflow and GitHub Secrets store.  To allow GitHub Actions to deploy resources within my Azure Subscription I have created an Azure Service Principal.  If you’ve never worked within them before I wrote an article covering how to create and work with them here.

     

 

 

run: >

        powershell -command "& '${{ env.OUTPUT_PATH }}\IaC\AzCLI\vmcreation.ps1'"

        -servicePrincipal ${{ secrets.SERVICE_PRINCIPAL_APPID }}

        -servicePrincipalSecret ${{ secrets.SERVICE_PRINCIPAL_SECRET }}

        -servicePrincipalTenantId ${{ secrets.SERVICE_PRINCIPAL_TENANTID }}

        -azureSubscriptionName ${{ secrets.AZURE_SUBSCRIPTION_ID }}

        -resourceGroupName %RESOURCE_GROUP%

        -resourceGroupNameRegion %RESOURCE_GROUP_REGION%

        -serverName %SERVER_NAME%

        -adminLogin %ADMIN_LOGIN%

        -adminPassword ${{ secrets.ADMIN_PASSWORD }}

 

 

 

 

 

 

 

 

For a full copy of this workflow file, you can find it here.

 

Monitoring the GitHub Action running

When the Action is running you can monitor its progress. When you navigate to your repository on the GitHub website you will see a tab called Actions, click into that will take you into the Workflow section.  You can create new workflows, edit workflows and monitor the progress of the workflows running.

GitHub Actions TabGitHub Actions Tab

 Monitoring GitHub ActionsMonitoring GitHub Actions

 

And once the workflow has completed you can check in your Azure subscription and hopefully see the resource created:

 

Azure ResourcesAzure Resources

 

Things to think about

 

My example workflow is a very basic one and the resource that I am deploying is a very basic one, however for me it was a great starting point to learn GitHub Actions.  I’ve seen my colleagues use it for much more complex deployments and workflows, for example Aaron Powell is using it to deploy his blog.

 

The repository I created to test out this deployment is a public one and the output of my workflow is available for anyone logged in or not to GitHub to view, which displays certain information that could be considered as sensitive such as my Azure Subscription ID and more importantly the Public IP address of my VM, which gives people with bad intentions an easy attack surface.  So, if you are testing GitHub Actions please be aware of this and vigilant on what you deploy in Azure and how it is secured.

 

I've recorded a video of me walking through the code and each step, this video can be found here: 

 

I’d love to hear how other IT Pros are using GitHub Actions to deploy infrastructure, so please do reach out and share your stories!

1 Comment

Thank you for Sharing with the community :cool: