Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New sample script: setup CI/CD workflow #5799

Open
Adam-it opened this issue Jan 28, 2024 · 4 comments · May be fixed by #6027
Open

New sample script: setup CI/CD workflow #5799

Adam-it opened this issue Jan 28, 2024 · 4 comments · May be fixed by #6027

Comments

@Adam-it
Copy link
Contributor

Adam-it commented Jan 28, 2024

The aim of this script is to prepare all the needed components and generate a CI/CD flow for either GitHub or Azure DevOps, depending on what the user passed to the script.
The script should have the following steps

  1. Generate a self-signed certificate and save the pfx- and cer-files and raw base64 of the cert
    if the script will be in PowerShell we may use the below script as a starting point, it generates the .pfx files and gets the base64 encoded cert string to txt file
$password = ConvertTo-SecureString -String "some-safe-password" -Force -AsPlainText
$cert = New-SelfSignedCertificate -NotBefore $(Get-Date).AddDays(-1) -NotAfter $(Get-Date).AddYears(1) -FriendlyName "CI-CD-Certificate" -CertStoreLocation cert:\CurrentUser\My -Subject "CN=CICDCertificate" -KeyAlgorithm RSA -KeyLength 2048 -KeyExportPolicy Exportable
$cert | Export-Certificate -Type cer -FilePath "$PWD/CI-CD-Certificate.cer" -Force
$cert | Export-PfxCertificate -FilePath "$PWD/CI-CD-Certificate.pfx" -Password $password
$cert | Remove-Item
$pfxBytes = Get-Content "selfSignedCertificate.pfx" -AsByteStream -Raw
[System.Convert]::ToBase64String($pfxBytes) | Out-File "selfSignedCertificate.txt"
  1. Create the application registration, upload the certificate and grant it admin consent
    we may use the following command for that, it will return the appId which we need
m365 aad app add --name 'My CI/CD Application' --apisApplication 'https://microsoft.sharepoint-df.com/Sites.FullControl.All' --certificateFile ./CI-CD-Certificate.cer --certificateDisplayName 'CICD Certificate' --grantAdminConsent
  1. create either a GitHub workflow or Azure DevOps pipeline
    we may use the spfx project github workflow add command or spfx project azuredevops pipeline add command for that. (the second one is not done yet so we should wait with this script until its ready)
Docs
Author me
Description setup a CI/CD pipeline using GitHub Workflows or Azure DevOps pipelines for your SPFx solution
Keywords deployment GitHub Azure DevOps Pipeline

Additional info

the spfx project azuredevops pipeline add command is not done yet so we should wait with this script until it's ready #5763

@Adam-it Adam-it added docs needs peer review Needs second pair of eyes to review the spec or PR labels Jan 28, 2024
@Adam-it
Copy link
Contributor Author

Adam-it commented Feb 19, 2024

@pnp/cli-for-microsoft-365-maintainers anyone has some 2 min for a second 👀 on this idea?

@waldekmastykarz
Copy link
Member

Great idea! Ship it!

@Adam-it Adam-it added help wanted good first issue and removed needs peer review Needs second pair of eyes to review the spec or PR labels Mar 2, 2024
@Adam-it
Copy link
Contributor Author

Adam-it commented Mar 2, 2024

Great idea! Ship it!

Awesome. I will open it up for a few days and as soon as I catch up and this will be free I will take it, since I already have it and waiting for ADO next 😉
...aaaaand next one will be gitlab support

@Adam-it
Copy link
Contributor Author

Adam-it commented Apr 28, 2024

I'll take it

@Adam-it Adam-it self-assigned this Apr 28, 2024
Adam-it added a commit to Adam-it/cli-microsoft365 that referenced this issue May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants