Highlight
Need to build WIKI flows in automated way for Azure Data Factory? Here’s how!
Check this out :)
The basics
Add below to pipelines in ADO and enjoy!
The Code
trigger:
branches:
include:
- master
paths:
include:
- pipeline
exclude:
- docs
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
persistCredentials: true
- task: PowerShell@2
inputs:
filePath: './scripts/generate-md-ado.ps1'
workingDirectory: $(System.DefaultWorkingDirectory)
- script: |
git config user.email [email protected]
git config user.name "your name"
git diff
git add .
git commit -m "version update [skip ci]"
git push origin HEAD:master
MermaidJS script
and powershell
$files = Get-ChildItem ./pipeline
if (Test-Path -LiteralPath ./docs) {
Remove-Item ./docs -Recurse
}
New-Item ./docs/ -ItemType Directory
foreach ($file in $files) {
$content = Get-Content -Path $file.FullName | ConvertFrom-Json
$fileName = $content.Name.Replace(" ", "-")
$fileName = "./docs/$($fileName).md"
"# $($content.Name)" > $fileName
"::: mermaid" >> $fileName
"graph LR;" >> $fileName
$linkId = 0
foreach ($activity in $content.properties.activities) {
$activityName = $activity.Name.Replace(" ","")
"$activityName[$($activity.Name)]" >> $fileName
foreach ($dependency in $activity.dependsOn) {
if ($dependency.dependencyConditions -eq "Succeeded") {
$color = "linkStyle $linkId stroke:green;"
} elseif ($dependency.dependencyConditions -eq "Failed") {
$color = "linkStyle $linkId stroke:red;"
}
$linkId += 1
$dependencyActivityName = $dependency.activity.Replace(" ", "")
"$dependencyActivityName --> $activityName" >> $fileName
"$color" >> $fileName
}
}
":::" >> $fileName
}
PlantUML script
$files = Get-ChildItem ./main/pipeline
foreach ($file in $files) {
$content = Get-Content -Path $file.FullName | ConvertFrom-Json
$fileName = "./main/docs/$($content.Name).puml"
"@startuml $($content.Name)" > $fileName
"left to right direction" >> $fileName
foreach ($activity in $content.properties.activities) {
$activityName = $activity.Name.Replace(" ","")
"rectangle $activityName" >> $fileName
foreach ($dependency in $activity.dependsOn) {
if ($dependency.dependencyConditions -eq "Succeeded") {
$color = "#green"
} elseif ($dependency.dependencyConditions -eq "Failed") {
$color = "#red"
}
$dependencyActivityName = $dependency.activity.Replace(" ", "")
"$dependencyActivityName --> $activityName $color" >> $fileName
}
}
"@enduml" >> $fileName
}
And that’s it!