6767 workflow_dispatch :
6868 inputs :
6969 subscriptionId :
70- description : ' Specific subscription ID to inventory (optional)'
70+ description : ' Specific subscription ID (optional)'
7171 required : false
72+ default : ' 00000000-0000-0000-0000-000000000000'
7273 resourceGroup :
73- description : ' Specific resource group to inventory (optional)'
74+ description : ' Specific resource group (optional)'
7475 required : false
76+ default : ' test-rg'
7577 reportName :
7678 description : ' Custom report name (optional)'
7779 required : false
78- default : ' AzureInventory '
80+ default : ' TestInventory '
7981
8082jobs :
8183 run-inventory :
82- runs-on : windows -latest
84+ runs-on : ubuntu -latest
8385 steps :
8486 - name : Checkout repository
8587 uses : actions/checkout@v3
@@ -101,36 +103,36 @@ jobs:
101103 shell : pwsh
102104 run : |
103105 $params = @{}
104-
106+
105107 # If subscription ID is provided
106108 if ("${{ github.event.inputs.subscriptionId }}" -ne "") {
107109 $params.Add("SubscriptionID", "${{ github.event.inputs.subscriptionId }}")
108110 }
109-
111+
110112 # If resource group is provided
111113 if ("${{ github.event.inputs.resourceGroup }}" -ne "") {
112114 $params.Add("ResourceGroup", "${{ github.event.inputs.resourceGroup }}")
113115 }
114-
116+
115117 # Set report name
116118 if ("${{ github.event.inputs.reportName }}" -ne "") {
117119 $params.Add("ReportName", "${{ github.event.inputs.reportName }}")
118120 } else {
119121 $params.Add("ReportName", "AzureInventory_$(Get-Date -Format 'yyyyMMdd')")
120122 }
121-
123+
122124 # Add any other parameters you want to use here
123125 # For example: $params.Add("SecurityCenter", $true)
124-
126+
125127 # Run ARI
126128 Invoke-ARI @params
127-
129+
128130 # Create artifacts directory
129131 New-Item -Path "$env:GITHUB_WORKSPACE/ari-reports" -ItemType Directory -Force
130-
132+
131133 # Move reports to artifacts directory
132134 Move-Item -Path ".\*.xlsx" -Destination "$env:GITHUB_WORKSPACE/ari-reports/" -Force
133-
135+
134136 if (Test-Path ".\*.drawio") {
135137 Move-Item -Path ".\*.drawio" -Destination "$env:GITHUB_WORKSPACE/ari-reports/" -Force
136138 }
@@ -148,14 +150,27 @@ jobs:
148150 # run: |
149151 # $storageAccount = "yourstorageaccount"
150152 # $container = "ari-reports"
151- #
153+ #
152154 # # Create the storage context
153155 # $ctx = New-AzStorageContext -StorageAccountName $storageAccount -UseConnectedAccount
154- #
156+ #
155157 # # Upload files to Azure Storage
156158 # Get-ChildItem -Path "$env:GITHUB_WORKSPACE/ari-reports" -File | ForEach-Object {
157159 # Set-AzStorageBlobContent -File $_.FullName -Container $container -Blob $_.Name -Context $ctx -Force
158160 # }
161+
162+ # Optional: Send email notification
163+ # - name: Send Email Notification
164+ # uses: dawidd6/action-send-mail@v3
165+ # with:
166+ # server_address: smtp.gmail.com
167+ # server_port: 465
168+ # username: ${{ secrets.EMAIL_USERNAME }}
169+ # password: ${{ secrets.EMAIL_PASSWORD }}
170+ # subject: Azure Resource Inventory Report
171+ # body: Azure Resource Inventory has completed. Reports are attached.
172+ 173+ # from: Azure Inventory <[email protected] > 159174```
160175
161176## Customizing the Workflow
@@ -203,18 +218,18 @@ To inventory specific subscriptions, you can modify the workflow:
203218 "00000000-0000-0000-0000-000000000000",
204219 "11111111-1111-1111-1111-111111111111"
205220 )
206-
221+
207222 foreach ($subId in $subscriptionIds) {
208223 Invoke-ARI -SubscriptionID $subId -ReportName "AzureInventory_${subId}_$(Get-Date -Format 'yyyyMMdd')"
209224 }
210225` ` `
211226
212227### Adding Email Notifications
213228
214- You can add email notifications using GitHub Actions:
229+ You can add email notifications using GitHub Actions by uncommenting the email notification section in the workflow :
215230
216231` ` ` yaml
217- - name : Send Email
232+ - name : Send Email Notification
218233 uses : dawidd6/action-send-mail@v3
219234 with :
220235 server_address : smtp.gmail.com
@@ -223,11 +238,15 @@ You can add email notifications using GitHub Actions:
223238 password : ${{ secrets.EMAIL_PASSWORD }}
224239 subject : Azure Resource Inventory Report
225240 body : Azure Resource Inventory has completed. Reports are attached.
226- attachments : ari-reports/*.xlsx
227241228242 from :
Azure Inventory <[email protected] > 229243` ` `
230244
245+ Before using this feature, make sure to add the following secrets to your repository:
246+
247+ - ` EMAIL_USERNAME`: Your email username/address
248+ - `EMAIL_PASSWORD` : Your email password or app-specific password
249+
231250# # Troubleshooting
232251
233252# ## Authentication Issues
@@ -264,4 +283,4 @@ If reports aren't generated:
264283
265284# # Conclusion
266285
267- GitHub Actions provides a flexible alternative to Azure Automation for running ARI on a schedule. This approach is particularly useful for teams already using GitHub for infrastructure management, allowing them to keep their inventory process alongside their infrastructure code.
286+ GitHub Actions provides a flexible alternative to Azure Automation for running ARI on a schedule. This approach is particularly useful for teams already using GitHub for infrastructure management, allowing them to keep their inventory process alongside their infrastructure code.
0 commit comments