【问题标题】:How to deploy from powershell script using github actions?如何使用 github 操作从 powershell 脚本进行部署?
【发布时间】:2020-08-05 01:54:51
【问题描述】:

我尝试在每次使用 GitHub 操作推送到我的 GitHub 存储库时部署到 siteCollection appcatalog。看到可以使用Office 365 CLI 操作,但只允许租户管理员部署。

在运行 powershell 脚本之前,我构建并创建了 .sppkg 文件。 所以我在 GitHub 操作中使用了 PowerShell 的 SharePointPnPPowerShellOnline 模块。我能够连接到该站点。

我无法找到访问 .sppkg 文件并将其部署到站点的方法

文件夹结构

下面是我的代码

Install-Module -Name SharePointPnPPowerShellOnline -Force -Verbose -Scope CurrentUser

$siteUrl = "https://test.sharepoint.com"
$username = "xyz@abc.com" 
$password = "myPassword"      

$encpassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $encpassword

Connect-PnPOnline -Url $siteUrl -Credentials $cred

Write-Host "logged in"

#code to access the sppkg file and deploy it to the site collection appcatalog

--------------------------------------------------------------------------------
$getTheSPPKGFile = *************

Add-PnPApp -Path $theSPPKGFile -Publish -Overwrite
--------------------------------------------------------------------------------

任何搜索都会导致租户管理方法。我没有租户管理员权限,只有网站集管理员权限。

谢谢

【问题讨论】:

    标签: powershell sharepoint-online github-actions spfx


    【解决方案1】:

    我今天能够使用 Github Actions 和 PnP powershell 实现这一目标,而无需任何 O365 CLI 步骤。

    我还创建了一个 ps1 文件,其中包含安装 PnP powershell 模块和使用 PnP powershell 将应用程序部署到目标站点的代码。

    这两个文件都可以在我的存储库中看到:

    yml file deployment script

    我的存储库中分支的路径是这个:

    my repository in github

    这里的关键是,要运行 PnP powershell,您需要使用 windows runner,并在运行步骤的 shell 参数中使用 shell 名称作为“powershell”。

    关于下载包的路径,可以通过上传artifact和download artifact步骤和这个表达式获取artifact下载路径:${{steps.packageDownloadStep.outputs.download-path}} where 'packageDownloadStep' 是 sppkg 文件的下载工件步骤的 ID。这可以在 yml 文件中检查。

    部署脚本 (ps1) 将在与 gulpfile.js 相同的文件夹中的根存储库中检查。您可以检查我在上面共享的存储库分支中的结构。

    【讨论】:

      猜你喜欢
      • 2020-10-21
      • 2020-03-29
      • 2020-03-29
      • 2020-12-03
      • 2023-03-19
      • 1970-01-01
      • 2020-06-15
      • 2018-05-12
      • 2020-11-03
      相关资源
      最近更新 更多