the Deploy section in the yaml file runs the Deploy.ps1 file (see below).
How do have the "PublishToEnviornment" pipeline use the artifacts from a specific release, such as this one with tag 230328.125132, (with this url https://github.com/iNECTA/HENDA/releases/tag/230328.125132)
Deploy.ps1:
Param(
[Parameter(HelpMessage = "The GitHub actor running the action", Mandatory = false)][string]actor,
[Parameter(HelpMessage = "The GitHub token running the action", Mandatory = false)][string]token,
[Parameter(HelpMessage = "Specifies the parent telemetry scope for the telemetry signal", Mandatory = false)][string]parentTelemetryScopeJson = '7b7d',
[Parameter(HelpMessage = "Projects to deploy", Mandatory = false)][string]projects = '',
[Parameter(HelpMessage = "Name of environment to deploy to", Mandatory = true)][string]environmentName,
[Parameter(HelpMessage = "Artifacts to deploy", Mandatory = true)][string]artifacts,
[Parameter(HelpMessage = "Type of deployment (CD or Publish)", Mandatory = false)][ValidateSet(′Ctype = "CD"
)
ErrorActionPreference="StoptelemetryScope = bcContainerHelperPath = $null
if ($projects -eq '') {
Write-Host "No projects to deploy"
}
else {
IMPORTANT: No code that can fail should be outside the try/catch
try {
. (Join-Path -Path PSScriptRoot−ChildPath"..\AL−BcContainerHelperPath = DownloadAndImportBcContainerHelper -baseFolder $ENV:GITHUB_WORKSPACE
import-module (Join-Path -path PSScriptRoot−ChildPath"..\TelemetryHelper.psm1"telemetryScope = CreateScope -eventId 'DO0075' -parentTelemetryScopeJson $parentTelemetryScopeJson
EnvironmentNameenvironmentName))
artifacts=artifacts.Replace('/',([System.IO.Path]::DirectorySeparatorChar)).Replace('',([System.IO.Path]::DirectorySeparatorChar))
apps=@()artifactsFolder = Join-Path ENV:GITHUBartifactsFolderCreated = artifacts -eq ".artifacts") {
artifactsFolder
}
if (artifacts−like"(ENV:GITHUB\_WORKSPACE)\*") {
if (Test-Path artifacts -PathType Container) {
projects.Split(',') | ForEach-Object {
project = refname = "project'"
artifacts -Filter "refname-Apps-*.*.*.*") | ForEach-Object { apps)) {
throw "There is no artifacts present in project-apps += @((Get-ChildItem -Path project-_.FullName })
}
}
elseif (Test-Path apps = artifacts was not found. Make sure that the artifact files exist and files are not corrupted."
}
}
elseif (artifacts -eq "prerelease" -or $artifacts -eq "draft") {
latest released version
releases=GetReleases−tokentoken -api_url ENV:GITHUB_REPOSITORY
if (release = _.prerelease -or artifacts -eq "prerelease") {
releases | Where-Object { -not (artifacts -eq "draft") {
releases | Select-Object -First 1
}
if (!(artifacts release"
}
New-Item artifactsFolderCreated = token -projects ENV:GITHUB_API_URL -repository release -path token -projects ENV:GITHUB_API_URL -repository release -path apps = @((Get-ChildItem -Path _.FullName })
if (!artifacts was not found on any release. Make sure that the artifact files exist and files are not corrupted."
}
}
else {
New-Item baseFolderCreated = allArtifacts = @(GetArtifacts -token ENV:GITHUB_API_URL -repository projects -Version allArtifacts += @(GetArtifacts -token ENV:GITHUB_API_URL -repository projects -Version allArtifacts) {
appFile = DownloadArtifact -token _ -path appFile)) {
throw "Unable to download artifact _.name)"
}
appFile)
}
}
else {
throw "Could not find any Apps artifacts for projects artifacts"
}
}
Write-Host "Apps to deploy"
$apps | Out-Host
Set-Location ENV:GITHUB_WORKSPACEif(−not(ENV:AuthContext)) {
throw "An environment secret for environment(environmentName) called AUTHCONTEXT containing authentication information for the environment was not found.You must create an environment secret."
}
authContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($ENV:AuthContext))
try {
authContextParams=authContext | ConvertFrom-Json | ConvertTo-HashTable
bcAuthContext = New-BcAuthContext @authContextParams
} catch {
throw "Authentication failed. ([environment]::Newline) (_.exception.message)"
}
envName=environmentName.Split(' ')[0]
Write-Host "(bcContainerHelperConfig.baseUrl.TrimEnd('/'))/(bcAuthContext.tenantId)/envresponse = Invoke-RestMethod -UseBasicParsing -Method Get -Uri "bcContainerHelperConfig.baseUrl.TrimEnd('/'))/bcAuthContext.tenantId)/response.Status -eq "DoesNotExist") {
OutputError -message "Environment with name response.Status -ne "Ready") {
OutputError -message "Environment with name ($response.Status))."
exit
}
try {
if (response.environmentType -eq 1) {
if (bcAuthContext.ClientSecret) {
Write-Host "Using S2S, publishing apps using automation API"
Publish-PerTenantExtensionApps -bcAuthContext bcAuthContext−environmentenvName -appFiles apps
}
else {
Write-Host "Publishing apps using development endpoint"
Publish-BcContainerApp -bcAuthContext bcAuthContext -environment apps -useDevEndpoint -checkAlreadyInstalled
}
}
else {
if (environmentName, which is a production environment"
}
else {
Check for AppSource App - cannot be deployed
Write-Host "Publishing apps using automation API"
Publish-PerTenantExtensionApps -bcAuthContext bcAuthContext−environmentenvName -appFiles apps
}
}
}
catch {
OutputError -message "Deploying to environmentName failed.($_.Exception.Message)"
exit
}
if (artifactsFolderCreated) {
Remove-Item artifactsFolder -Recurse -Force
}
TrackTrace -telemetryScope $telemetryScope
}
catch {
OutputError -message "Deploy action failed.([environment]::Newline)Error:(([environment]::Newline)Stacktrace: _.scriptStackTrace)"
TrackException -telemetryScope _
}
finally {
CleanupAfterBcContainerHelper -bcContainerHelperPath $bcContainerHelperPath
}
}