-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeployRDLfiles.yml
More file actions
111 lines (99 loc) · 3.57 KB
/
DeployRDLfiles.yml
File metadata and controls
111 lines (99 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
trigger:
branches:
include:
- main
stages:
- stage: Build
displayName: "Build RDL Artifacts"
jobs:
- job: BuildRDL
pool:
vmImage: 'windows-latest'
steps:
- checkout: self
- powershell: |
$rdlFolder = "$(Build.SourcesDirectory)\reports"
$artifactDir = "$(Build.ArtifactStagingDirectory)"
$newManifestPath = Join-Path $artifactDir "rdl-manifest.json"
# Step 1: Compute hashes
$newHashes = @()
Get-ChildItem -Path $rdlFolder -Filter *.rdl -File -Recurse | ForEach-Object {
$hash = Get-FileHash -Algorithm SHA256 -Path $_.FullName
$relativePath = $_.FullName.Substring($rdlFolder.Length+1)
$folder = Split-Path $relativePath -Parent
$newHashes += [PSCustomObject]@{
FileName = $_.Name
RelativePath = $relativePath
Folder = $folder
Hash = $hash.Hash
FullPath = $_.FullName
}
}
# Step 2: Load old manifest if exists
$oldManifestPath = "$(Pipeline.Workspace)\previous\rdl\rdl-manifest.json"
$oldHashes = @()
if (Test-Path $oldManifestPath) {
$oldHashes = Get-Content $oldManifestPath | ConvertFrom-Json
}
# Step 3: Compare
$changed = @()
foreach ($n in $newHashes) {
$match = $oldHashes | Where-Object { $_.FileName -eq $n.FileName -and $_.RelativePath -eq $n.RelativePath }
if (-not $match) {
Write-Host "NEW report: $($n.FileName)"
$changed += $n
}
elseif ($match.Hash -ne $n.Hash) {
Write-Host "CHANGED report: $($n.FileName)"
$changed += $n
}
else {
Write-Host "UNCHANGED report: $($n.FileName)"
}
}
# Step 4: Copy only changed files to artifact directory
foreach ($c in $changed) {
$targetDir = Join-Path $artifactDir (Split-Path $c.RelativePath -Parent)
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
Copy-Item $c.FullPath (Join-Path $artifactDir $c.RelativePath) -Force
}
# Step 5: Save new manifest
$newHashes | ConvertTo-Json -Depth 5 | Out-File $newManifestPath
displayName: "Generate manifest and copy changed reports"
- publish: $(Build.ArtifactStagingDirectory)
artifact: rdl
displayName: "Publish RDL artifacts"
- stage: Deploy
displayName: "Deploy to Power BI"
dependsOn: Build
jobs:
- deployment: DeployReports
environment: powerbi-dev
pool:
vmImage: 'windows-latest'
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: rdl
- powershell: |
param(
[string]$TenantId,
[string]$ClientId,
[string]$ClientSecret,
[string]$WorkspaceName
)
# Import the deployment script
. "$(Pipeline.Workspace)\rdl\deploy-rdl.ps1" `
-TenantId $TenantId `
-ClientId $ClientId `
-ClientSecret $ClientSecret `
-WorkspaceName $WorkspaceName `
-ManifestPath "$(Pipeline.Workspace)\rdl\rdl-manifest.json"
displayName: "Deploy RDL files to Power BI"
env:
TenantId: $(TenantId)
ClientId: $(ClientId)
ClientSecret: $(ClientSecret)
WorkspaceName: $(WorkspaceName)