# <copyright file="New-DotNetBuildGitHubWorkflow.ps1" company="Endjin Limited">
# Copyright (c) Endjin Limited. All rights reserved.
# </copyright>

    Generates a GitHub Actions workflow that runs a .NET CI build.
    Generates a GitHub Actions workflow that consumes the resuable workflow:
    to run the standard .NET build process available in this module.
    PS C:\> New-DotNetBuildGitHubWorkflow -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
    The destination path for the generated build script.
    When true, any existing file.

function New-DotNetBuildGitHubWorkflow
    param (
        [string] $OutputPath = ".github/workflows/build.yml",

        [switch] $Force

    $templatePath = "$PSScriptRoot/../../templates/dotnetbuild-gha-workflow.tmpl.yml"

    # 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