functions/template-helpers/New-DotNetBuildGitHubWorkflow.ps1
# <copyright file="New-DotNetBuildGitHubWorkflow.ps1" company="Endjin Limited"> # Copyright (c) Endjin Limited. All rights reserved. # </copyright> <# .SYNOPSIS Generates a GitHub Actions workflow that runs a .NET CI build. .DESCRIPTION Generates a GitHub Actions workflow that runs the standard .NET build process available in this module. Additionally the workflow handles publishing NuGet packages to GitHub packages and nuget.org. .EXAMPLE PS C:\> New-DotNetBuildGitHubWorkflow -NuGetOrgApiKeySecretName ./src/MySolution/MySolution.sln -Path .github/workflows/build.yml Generates a build script in the current directory configured to build the specified solution. .PARAMETER NuGetOrgApiKeySecretName The name of the GitHub secret that contains the APIKey used for publishing to nuget.org. .PARAMETER Path The destination path for the generated build script. .PARAMETER Force When true, any existing file. #> function New-DotNetBuildGitHubWorkflow { [CmdletBinding()] param ( [Parameter(Mandatory=$true)] [string] $NuGetOrgApiKeySecretName, [Parameter()] [string] $OutputPath = ".github/workflows/build.yml", [Parameter()] [switch] $Force ) $templatePath = "$PSScriptRoot/../../templates/dotnetbuild-gha-workflow.yml.tmpl" # If we're using the default value of OutputPath (i.e. we've not specified it when calling this function), # then it won't be part of the PSBoundParameters collection, so we need to add it before calling the # underlying template helper if ("OutputPath" -notin $PSBoundParameters.Keys) { $PSBoundParameters.Add("OutputPath", $OutputPath) } _executeTemplate -TemplatePath $templatePath @PSBoundParameters } |