Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
markgar committed Dec 10, 2024
1 parent 7316aeb commit 9e4dec8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 53 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ jobs:
run: |
Install-Module Az -Force
Import-Module Az.Accounts -Force
Install-Module FabricPS -Force
Import-Module FabricPS -Force
- name: Connect with SPN
shell: pwsh
Expand Down
50 changes: 50 additions & 0 deletions Deploy-FabricItems.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function Deploy-FabricItems {
param (
[string]$DestinationWorkspaceId,

[ValidateSet("Notebook")]
[string]$Type
)

# Get all items of the specified type in the destination workspace
$items = Get-FabricItems -Type $Type -WorkspaceId $DestinationWorkspaceId

# Get all directories in the current directory that end with .Notebook
$itemDirs = Get-ChildItem -Directory | Where-Object { $_.Name -like "*.$Type" }

# Loop through each directory in the source which is a notebook
foreach ($dir in $itemDirs) {

# grab the item name, which is before the '.' in the directory name
$ItemName = $dir.Name.Split('.')[0]

$existingItem = $items.value | Where-Object { $_.DisplayName -eq $ItemName }

# Check if the notebook already exists in the destination workspace
if ($null -eq $existingItem) {

$newItem = New-FabricItem `
-WorkspaceId $DestinationWorkspaceId `
-DisplayName $ItemName `
-Type $Type

# Set the notebookToUpdateId to the new notebook's Id so I can set the payload
$itemToUpdateId = $newItem.Id
} else {
# Set the notebookToUpdateId to the existing notebook's Id so I can set the payload
$itemToUpdateId = $existingItem.Id
}

if ($Type -eq 'Notebook') {
$payload = Get-NotebookDefinitionPayload -dir $dir
}

Update-FabricItemDefinition `
-WorkspaceId $DestinationWorkspaceId `
-ItemId $itemToUpdateId `
-Definition $payload

# todo - compare the list of notebooks in the destination that are in the source code
# if the notebook is not in the source code, delete it from the destination
}
}
54 changes: 3 additions & 51 deletions deploy.ps1
Original file line number Diff line number Diff line change
@@ -1,56 +1,8 @@
function Deploy-FabricItems {
param (
[string]$DestinationWorkspaceId,

[ValidateSet("Notebook")]
[string]$Type
)

# Get all items of the specified type in the destination workspace
$items = Get-FabricItems -Type $Type -WorkspaceId $DestinationWorkspaceId

# Get all directories in the current directory that end with .Notebook
$itemDirs = Get-ChildItem -Directory | Where-Object { $_.Name -like "*.$Type" }

# Loop through each directory in the source which is a notebook
foreach ($dir in $itemDirs) {

# grab the item name, which is before the '.' in the directory name
$ItemName = $dir.Name.Split('.')[0]

$existingItem = $items.value | Where-Object { $_.DisplayName -eq $ItemName }

# Check if the notebook already exists in the destination workspace
if ($null -eq $existingItem) {

$newItem = New-FabricItem `
-WorkspaceId $DestinationWorkspaceId `
-DisplayName $ItemName `
-Type $Type

# Set the notebookToUpdateId to the new notebook's Id so I can set the payload
$itemToUpdateId = $newItem.Id
} else {
# Set the notebookToUpdateId to the existing notebook's Id so I can set the payload
$itemToUpdateId = $existingItem.Id
}

if ($Type -eq 'Notebook') {
$payload = Get-NotebookDefinitionPayload -dir $dir
}

Update-FabricItemDefinition `
-WorkspaceId $DestinationWorkspaceId `
-ItemId $itemToUpdateId `
-Definition $payload

# todo - compare the list of notebooks in the destination that are in the source code
# if the notebook is not in the source code, delete it from the destination
}
}

Install-Module FabricPS -Force
Import-Module FabricPS -Force
Get-InstalledModule FabricPS

. ./Deploy-FabricItems.ps1

# hard coded workspace id for now
$destinationWorkspaceId = 'f4a80368-71ee-4e0f-8734-1e3c32e28d2a'
Expand Down

0 comments on commit 9e4dec8

Please sign in to comment.