-
Notifications
You must be signed in to change notification settings - Fork 53
Publish module to ACR #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c1a09f3
Add steps to deploy module to ACR
vthiebaut10 5a7cdab
move servicegrouproot folder to ev2specs
vthiebaut10 b578555
Use copy file to simplify pipeline operation
vthiebaut10 49c6126
Use archive file to simplify pipeline
vthiebaut10 bb646e2
Update .pipelines/SecretManagement-Official.yml
vthiebaut10 c1f1433
Refactor environment variable setup
vthiebaut10 4ee9a33
Just fix some verbose
vthiebaut10 9360880
Try removing the version file since it doesn't seem to be used
vthiebaut10 54110a6
build version is actually required
vthiebaut10 ffe015a
fix bugs and typos
vthiebaut10 391fa53
remove some debug statements
vthiebaut10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "$schema": "https://ev2schema.azure.net/schemas/2020-01-01/rolloutSpecification.json", | ||
| "contentVersion": "1.0.0.0", | ||
| "RolloutMetadata": { | ||
| "ServiceModelPath": "ServiceModel.json", | ||
| "ScopeBindingsPath": "ScopeBindings.json", | ||
| "Name": "OneBranch-Demo-Container-Deployment", | ||
| "RolloutType": "Major", | ||
| "BuildSource": { | ||
| "Parameters": { | ||
| "VersionFile": "buildver.txt" | ||
| } | ||
| }, | ||
| "Notification": { | ||
| "Email": { | ||
| "To": "default" | ||
| } | ||
| } | ||
| }, | ||
| "OrchestratedSteps": [ | ||
| { | ||
| "Name": "UploadSecretManagementToACR", | ||
| "TargetType": "ServiceResource", | ||
| "TargetName": "SecretManagementToACR", | ||
| "Actions": ["Shell/Run"] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "$schema": "https://ev2schema.azure.net/schemas/2020-01-01/scopeBindings.json", | ||
| "contentVersion": "0.0.0.1", | ||
| "scopeBindings": [ | ||
| { | ||
| "scopeTagName": "Global", | ||
| "bindings": [ | ||
| { | ||
| "find": "__SUBSCRIPTION_ID__", | ||
| "replaceWith": "$azureSubscriptionId()" | ||
| }, | ||
| { | ||
| "find": "__RESOURCE_GROUP__", | ||
| "replaceWith": "$azureResourceGroup()" | ||
| }, | ||
| { | ||
| "find": "__BUILD_VERSION__", | ||
| "replaceWith": "$buildVersion()" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
60 changes: 60 additions & 0 deletions
60
Ev2Specs/ServiceGroupRoot/SecretManagementToACR.Rollout.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| { | ||
| "$schema": "https://ev2schema.azure.net/schemas/2020-01-01/rolloutParameters.json", | ||
| "contentVersion": "1.0.0.0", | ||
| "shellExtensions": [ | ||
| { | ||
| "name": "Run", | ||
| "type": "Run", | ||
| "properties": { | ||
| "maxExecutionTime": "PT2H" | ||
| }, | ||
| "package": { | ||
| "reference": { | ||
| "path": "Shell/Run.tar" | ||
| } | ||
| }, | ||
| "launch": { | ||
| "command": [ | ||
| "/bin/bash", | ||
| "-c", | ||
| "pwsh ./Run/Run.ps1" | ||
| ], | ||
| "environmentVariables": [ | ||
| { | ||
| "name": "SECRET_MANAGEMENT_MODULE", | ||
| "reference": | ||
| { | ||
| "path": "SrcFiles\\Microsoft.PowerShell.SecretManagement.nupkg" | ||
| } | ||
| }, | ||
| { | ||
| "name": "DESTINATION_ACR_NAME", | ||
| "value": "default" | ||
| }, | ||
| { | ||
| "name": "MI_NAME", | ||
| "value": "default" | ||
| }, | ||
| { | ||
| "name": "MI_CLIENTID", | ||
| "value": "default" | ||
| }, | ||
| { | ||
| "name": "SECRET_MANAGEMENT_VERSION", | ||
| "value": "default" | ||
| }, | ||
| { | ||
| "name": "DESTINATION_ACR_URI", | ||
| "value": "default" | ||
| } | ||
| ], | ||
| "identity": { | ||
| "type": "userAssigned", | ||
| "userAssignedIdentities": [ | ||
| "default" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| { | ||
| "$schema": "https://ev2schema.azure.net/schemas/2020-01-01/serviceModel.json", | ||
| "contentVersion": "1.0.0.0", | ||
| "ServiceMetadata": { | ||
| "ServiceGroup": "OneBranch-SecretManagement", | ||
| "Environment": "Test" | ||
| }, | ||
| "ServiceResourceGroupDefinitions": [ | ||
| { | ||
| "Name": "OneBranch-SecretManagement-RGDef", | ||
| "ServiceResourceDefinitions": [ | ||
| { | ||
| "Name": "OneBranch-SecretManagement.Shell-SRDef", | ||
| "composedOf": { | ||
| "extension": { | ||
| "shell": [ | ||
| { | ||
| "type": "Run", | ||
| "properties": { | ||
| "imageName": "adm-mariner-20-l", | ||
| "imageVersion": "v5" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "ServiceResourceGroups": [ | ||
| { | ||
| "AzureResourceGroupName": "default", | ||
| "Location": "East US", | ||
| "InstanceOf": "OneBranch-SecretManagement-RGDef", | ||
| "AzureSubscriptionId": "default", | ||
| "scopeTags": [ | ||
| { | ||
| "name": "Global" | ||
| } | ||
| ], | ||
| "ServiceResources": [ | ||
| { | ||
| "Name": "SecretManagementToACR", | ||
| "InstanceOf": "OneBranch-SecretManagement.Shell-SRDef", | ||
| "RolloutParametersPath": "SecretManagementToACR.Rollout.json" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # ensure SAS variables were passed in | ||
| if ($env:SECRET_MANAGEMENT_MODULE -eq $null) | ||
| { | ||
| Write-Verbose -Verbose "SECRET_MANAGEMENT_MODULE variable didn't get passed correctly" | ||
| return 1 | ||
| } | ||
|
|
||
| if ($env:SECRET_MANAGEMENT_VERSION -eq $null) | ||
| { | ||
| Write-Verbose -Verbose "SECRET_MANAGEMENT_VERSION variable didn't get passed correctly" | ||
| return 1 | ||
| } | ||
|
|
||
| if ($env:DESTINATION_ACR_NAME -eq $null) | ||
| { | ||
| Write-Verbose -Verbose "DESTINATION_ACR_NAME variable didn't get passed correctly" | ||
| return 1 | ||
| } | ||
|
|
||
| if ($env:DESTINATION_ACR_URI -eq $null) | ||
| { | ||
| Write-Verbose -Verbose "DESTINATION_ACR_URI variable didn't get passed correctly" | ||
| return 1 | ||
| } | ||
|
|
||
| if ($env:MI_CLIENTID -eq $null) | ||
| { | ||
| Write-Verbose -Verbose "MI_CLIENTID variable didn't get passed correctly" | ||
| return 1 | ||
| } | ||
|
|
||
|
|
||
| try { | ||
| Write-Verbose -Verbose "SecretManagement: $env:SECRET_MANAGEMENT_MODULE" | ||
| Write-Verbose -Verbose "Version: $env:SECRET_MANAGEMENT_VERSION" | ||
| Write-Verbose -Verbose "acrname: $env:DESTINATION_ACR_NAME" | ||
| Write-Verbose -Verbose "acruri: $env:DESTINATION_ACR_URI" | ||
| Write-Verbose -Verbose "MI client Id: $env:MI_CLIENTID" | ||
|
|
||
| $secretManagementFileName = "Microsoft.PowerShell.SecretManagement.$($env:SECRET_MANAGEMENT_VERSION).nupkg" | ||
|
|
||
| Write-Verbose -Verbose "Download files" | ||
| Invoke-WebRequest -Uri $env:SECRET_MANAGEMENT_MODULE -OutFile $secretManagementFileName | ||
|
|
||
| $moduleExists = Test-Path $secretManagementFileName | ||
| Write-Verbose -Verbose "Module $secretManagementFileName exists: $moduleExists" | ||
|
|
||
| # Install PSResourceGet 1.1.0 | ||
| Write-Verbose "Download PSResourceGet version 1.1.0" | ||
| Register-PSRepository -Name CFS -SourceLocation "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/powershell/nuget/v2" -InstallationPolicy Trusted | ||
| Install-Module -Repository CFS -Name Microsoft.PowerShell.PSResourceGet -RequiredVersion '1.1.0' -Verbose | ||
| Import-Module Microsoft.PowerShell.PSResourceGet | ||
| Get-Module | ||
|
|
||
| # Login to Azure CLI using Managed Identity | ||
| Write-Verbose -Verbose "Login cli using managed identity" | ||
| az login --identity --username $env:MI_CLIENTID | ||
|
|
||
| # Register the target ACR as a PSResourceGet repository | ||
| Write-Verbose -Verbose "Register ARC as a PSResourceGet reposirory" | ||
| Register-PSResourceRepository -Uri $env:DESTINATION_ACR_URI -Name $env:DESTINATION_ACR_NAME -Trusted -Verbose | ||
|
|
||
| Get-PSResourceRepository | ||
|
|
||
| #Publish SecretManagement to ACR | ||
| Write-Verbose -Verbose "Publish SecretManagement $secretManagementFileName to ACR $env:DESTINATION_ACR_NAME" | ||
| $prefix = "public/psresource" | ||
| Publish-PSResource -Repository $env:DESTINATION_ACR_NAME -NupkgPath $secretManagementFileName -ModulePrefix $prefix -Confirm:$false | ||
| } | ||
| catch { | ||
|
|
||
| $_.Exception | Format-List -Force | ||
|
|
||
| return 1 | ||
| } | ||
|
|
||
| return 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 2.0.0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.