GitHub Runner Image #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub Runner Image | |
on: | |
workflow_dispatch: | |
inputs: | |
resourceGroupName: | |
description: 'Resource group name' | |
required: true | |
default: 'rg-apai' | |
resourceGroupNameVMSS: | |
description: 'Resource group name for VMSS' | |
required: true | |
default: 'rg-vmss' | |
location: | |
description: 'Location' | |
required: true | |
default: 'australiaeast' | |
imageType: | |
description: 'Image type' | |
required: true | |
default: 'UbuntuMinimal' | |
type: choice | |
options: | |
- 'UbuntuMinimal' | |
- 'Ubuntu2004' | |
- 'Ubuntu2204' | |
- 'Windows2019' | |
- 'Windows2022' | |
generateImage: | |
description: 'Generate Image' | |
required: true | |
default: false | |
type: boolean | |
createVMSS: | |
description: 'Create VMSS' | |
required: true | |
default: false | |
type: boolean | |
updateVMSS: | |
description: 'Update VMSS' | |
required: true | |
default: true | |
type: boolean | |
debugPacker: | |
description: 'Debug Packer Image Creation' | |
required: true | |
default: false | |
type: boolean | |
jobs: | |
image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out | |
uses: actions/checkout@v2 | |
- name: Set up Azure CLI | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
enable-AzPSSession: true | |
- name: Clone Repository | |
uses: azure/powershell@v1 | |
with: | |
azPSVersion: 'latest' | |
inlineScript: | | |
. (Join-Path $env:GITHUB_WORKSPACE '.scripts' 'Functions.ps1') | |
Copy-Repository -workingDirectory $env:GITHUB_WORKSPACE | |
- name: Generate Image | |
if: ${{ inputs.generateImage }} | |
uses: azure/powershell@v1 | |
env: | |
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} | |
with: | |
azPSVersion: 'latest' | |
inlineScript: | | |
$credentials = $env:AZURE_CREDENTIALS | ConvertFrom-Json | |
. (Join-Path $env:GITHUB_WORKSPACE '.scripts' 'Functions.ps1') | |
Add-Image -workingDirectory $env:GITHUB_WORKSPACE ` | |
-subscriptionId $credentials.subscriptionId ` | |
-tenantId $credentials.tenantId ` | |
-servicePrincipalId $credentials.clientId ` | |
-servicePrincipalKey $credentials.clientSecret ` | |
-resourceGroupName ${{ inputs.resourceGroupName }} ` | |
-imageType ${{ inputs.imageType }} ` | |
-location ${{ inputs.location }} ` | |
-debugPacker ${{ inputs.debugPacker }} | |
- name: Create VMSS | |
if: ${{ inputs.createVMSS }} | |
uses: azure/powershell@v1 | |
with: | |
azPSVersion: 'latest' | |
inlineScript: | | |
. (Join-Path $env:GITHUB_WORKSPACE '.scripts' 'Functions.ps1') | |
Add-VMSS -resourceGroupName ${{ inputs.resourceGroupNameVMSS }} -imageType ${{ inputs.imageType }} -location ${{ inputs.location }} | |
- name: Update VMSS | |
if: ${{ inputs.updateVMSS }} | |
uses: azure/powershell@v1 | |
with: | |
azPSVersion: 'latest' | |
inlineScript: | | |
. (Join-Path $env:GITHUB_WORKSPACE '.scripts' 'Functions.ps1') | |
Edit-VMSS -resourceGroupName ${{ inputs.resourceGroupNameVMSS }} -imageType ${{ inputs.imageType }} |