0

I am trying to deploy to siteCollection appcatalog on each push to my GitHub repository using GitHub actions. Saw that it's possible using Office 365 CLI action, but that only allows tenant admins to deploy.

Before I run the powershell script I build and create the .sppkg file. So I used PowerShell's SharePointPnPPowerShellOnline Module in GitHub actions. I was able to connect to the site.

I'm not able to find a way to access the .sppkg file and deploy it to the site

Folder structure

VSCode Folder Tree

Below is my code

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

$siteUrl = "https://test.sharepoint.com"
$username = "[email protected]" 
$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
--------------------------------------------------------------------------------

Any search is resulting to tenant admin approach. I don't have tenant admin access, only site collection admin access.

Thank you

1 Answer 1

1

I was able to achieve this today using Github Actions and PnP powershell without any O365 CLI step.

I also created a ps1 file which contains code to install PnP powershell module and to deploy app to the target site using PnP powershell.

Both the files can be seen in my repository here:

yml file deployment script

The path to the branch in my repository is this one:

my repository in github

The key thing here is that for PnP powershell to run, you would need to use a windows runner and use the shell name as 'powershell' in the shell parameter of the run step.

Regarding the path of the downloaded package, you can get it by using upload artifact and download artifact steps and this expression to get the path where artifact is downloaded: ${{steps.packageDownloadStep.outputs.download-path}} where 'packageDownloadStep' is the id given to the download-artifact step for the sppkg file. This can be checked in the yml file.

The deployment script (ps1) will be checked in the repository at the root , in the same folder as gulpfile.js. You can check the structure in the branch of my repository which I have shared above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.