Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
segraef committed Oct 4, 2023
1 parent 4e90423 commit 81cb72b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 25 deletions.
76 changes: 56 additions & 20 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,50 @@
name: Azure Actions

on:
workflow_dispatch:
inputs:
name:
description: 'Person to greet'
required: true
default: 'You'
home:
description: 'location'
required: false
default: 'The Universe'

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
Expand All @@ -22,13 +55,7 @@ jobs:
updateVMSS: [true, false]

steps:
- name: Hello
shell: pwsh
run: |
echo "Hello ${{ github.event.inputs.name }}!"
echo "- in ${{ github.event.inputs.home }}!"
- name: Check out code
- name: Check out
uses: actions/checkout@v2

- name: Set up Azure CLI
Expand All @@ -45,17 +72,26 @@ jobs:
- name: Generate Image
if: matrix.generateImage == 'true'
run: |
$creds = ${{ secrets.AZURE_CREDENTIALS }} | ConvertFrom-Json
./.scripts/functions.ps1
New-Image -workingDirectory ${{ github.workspace }} -subscriptionId ${{ secrets.SUBSCRIPTION_ID }} -tenantId ${{ secrets.TENANT_ID }} -servicePrincipalId ${{ secrets.servicePrincipalId }} -servicePrincipalKey ${{ secrets.servicePrincipalKey }} -resourceGroupName ${{ secrets.RESOURCE_GROUP_NAME }} -imageType ${{ secrets.IMAGE_TYPE }} -location ${{ secrets.LOCATION }} -debugPacker ${{ secrets.DEBUG_PACKER }}
New-Image -workingDirectory ${{ github.workspace }} `
-subscriptionId $creds.subscriptionId `
-tenantId $creds.tenantId `
-servicePrincipalId $creds.clienttId `
-servicePrincipalKey $creds.clientSecret `
-resourceGroupName ${{ inputs.resourceGroupName }} `
-imageType ${{ inputs.imageType }} `
-location ${{ inputs.location }} `
-debugPacker ${{ inputs.debugPacker }}
- name: Create VMSS
if: matrix.createVMSS == 'true'
run: |
./.scripts/functions.ps1
New-VMSS -resourceGroupName ${{ secrets.RESOURCE_GROUP_NAME_VMSS }} -imageType ${{ secrets.IMAGE_TYPE }} -location ${{ secrets.LOCATION }}
New-VMSS -resourceGroupName ${{ inputs.resourceGroupNameVMSS }} -imageType ${{ inputs.imageType }} -location ${{ inputs.location }}
- name: Update VMSS
if: matrix.updateVMSS == 'true'
run: |
./.scripts/functions.ps1
Update-VMSS -resourceGroupNameVMSS ${{ secrets.RESOURCE_GROUP_NAME_VMSS }} -imageType ${{ secrets.IMAGE_TYPE }}
Update-VMSS -resourceGroupNameVMSS ${{ inputs.resourceGroupNameVMSS }} -imageType ${{ inputs.imageType }}
8 changes: 4 additions & 4 deletions .pipelines/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ stages:
scriptLocation: inlineScript
inlineScript: |
. $(Build.SourcesDirectory)/.scripts/Functions.ps1
Clone-Repository -workingDirectory $(Build.SourcesDirectory)
Copy-Repository -workingDirectory $(Build.SourcesDirectory)
- task: AzureCLI@2
displayName: Generate ${{ parameters.imageType }}
Expand All @@ -93,7 +93,7 @@ stages:
addSpnToEnvironment: true
inlineScript: |
. $(Build.SourcesDirectory)/.scripts/Functions.ps1
Generate-Image `
Add-Image `
-workingDirectory $(Build.SourcesDirectory) `
-subscriptionId ${{ parameters.subscriptionId }} `
-resourceGroupName ${{ parameters.resourceGroupName }} `
Expand All @@ -111,7 +111,7 @@ stages:
inlineScript: |
. $(Build.SourcesDirectory)/.scripts/Functions.ps1
Create-VMSS `
Add-VMSS `
-resourceGroupName ${{ parameters.resourceGroupNameVMSS }} `
-resourceGroupNameImage ${{ parameters.resourceGroupName }} `
-imageType ${{ parameters.imageType }} `
Expand All @@ -127,7 +127,7 @@ stages:
inlineScript: |
. $(Build.SourcesDirectory)/.scripts/Functions.ps1
Update-VMSS `
Edit-VMSS `
-resourceGroupName ${{ parameters.resourceGroupNameVMSS }} `
-resourceGroupNameImage ${{ parameters.resourceGroupName }} `
-imageType ${{ parameters.imageType }}
2 changes: 1 addition & 1 deletion .scripts/Functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Copy-Repository {
}

# Function to generate the specified image
function Edit-Image {
function Add-Image {
[CmdletBinding(SupportsShouldProcess=$false)]
param (
[string]$workingDirectory = $pwd,
Expand Down

0 comments on commit 81cb72b

Please sign in to comment.