Skip to content

Commit 1b87cc8

Browse files
issue-8: Added github action
1 parent 7b84479 commit 1b87cc8

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

.github/workflows/publish-doc.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Generate ARM templates docs
2+
on:
3+
push:
4+
branches: [ main ]
5+
jobs:
6+
arm_docs:
7+
name: Generate ARM template docs
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Generate Reference Documentation
13+
id: Container_Name
14+
run: |
15+
Install-Module -Name 'PSDocs.Azure' -Repository PSGallery -force;
16+
Get-AzDocTemplateFile | ForEach-Object {
17+
$TemplateFile = Get-Item -Path $_.TemplateFile;
18+
if ($TemplateFile.BaseName -eq 'azuredeploy') {
19+
$Template = Get-Content $TemplateFile |ConvertFrom-Json;
20+
$RepoName = $TemplateFile.Directory.Parent.Name;
21+
$Version = $Template.ContentVersion;
22+
$ReadmeHeader = "[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FArmReference%2F$($RepoName)%2F$($Version)%2Fazuredeploy.json)"
23+
}
24+
$Container = (Get-Date).GetDateTimeFormats()[1];
25+
Invoke-PSDocument -Module PSDocs.Azure -OutputPath "out/docs" -InputObject $TemplateFile.FullName -InstanceName $TemplateFile.BaseName;
26+
};
27+
New-Item docs -ItemType Directory -Force;
28+
$Readme = Get-Content "out/docs/azuredeploy.md";
29+
Write-Output $ReadmeHeader |Out-File "README.md" -Force;
30+
Write-Output $Readme |Out-File "README.md" -Append;
31+
Remove-Item "out/docs/azuredeploy.md"
32+
Move-Item "out/docs/*.md" docs/ -Force;
33+
echo "::set-output name=CONTAINER::$($Container)"
34+
shell: pwsh
35+
- name: Setup Git Config
36+
run:
37+
git config user.name "GitHub Action";
38+
git config user.email "<>";
39+
- name: Update ReadME
40+
run:
41+
git add *;
42+
git commit -m "Updating README with latest documentation";
43+
git push origin main
44+
- name: Send to Azure Storage Account
45+
uses: azure/CLI@v1
46+
with:
47+
azcliversion: 2.34.1
48+
inlinescript: |
49+
az storage container create --name '${{steps.Container_Name.outputs.CONTAINER}}' --account-name ${{ secrets.AccountName }} --account-key ${{ secrets.AccountKey }} --public-access container
50+
az storage blob upload-batch --account-name ${{ secrets.AccountName }} --account-key ${{ secrets.AccountKey }} -d ${{steps.Container_Name.outputs.CONTAINER}} -s reference --overwrite true --destination-path Microsoft.Storage/reference

azuredeploy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"variables": {
1919
"Provider": "/Microsoft.Storage",
20-
"Resource": "/storageAccounts",
20+
"Resource": "/reference",
2121
"templateUri": "[concat('https://',parameters('StorageAccountName'),'.blob.core.windows.net/',parameters('ContainerName'),variables('Provider'),variables('Resource'))]"
2222
},
2323
"resources": [

0 commit comments

Comments
 (0)