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 command: spfx project github workflow add #5209
Comments
@pnp/cli-for-microsoft-365-maintainers what do you think? |
Great idea! Few considerations:
|
I agree, will update the spec
I thought exactly the same, that's why it is not in the spec but as a suggestion. Ok for now let's leave it
Awesome idea. Will do some research in that area. @waldekmastykarz thanks for the feedback 👍 |
Ok, @waldekmastykarz I updated the spec. |
@waldekmastykarz this looks promising js-yaml https://github.com/nodeca/js-yaml#readme Allows to convert both ways from object to yaml and the other way around. Which might be helpful if we want to update the workflow template in the future. We could keep the object JSON as the workflow template. What do you think? We could at least try with this and check if it will work. We also should double check for security issues. @pnp/cli-for-microsoft-365-maintainers any alternative suggestions? |
Lack of activity on the repo is concerning. I suggest that we look for alternatives. |
Spec looks good. One detail we miss is the name of the file to create on disk and what the command will do in case of a collision. |
Ok will research something more
Those are good questions. Usually when I was working with pipelines the filename a bit described what was going to happen. Like 'release_main.yml' means that it will release the product from main branch. |
So @Adam-it, so this command will generate a yml file for you in the directory where you are running it, so you can commit it to the repo and make GH run it. Is that the idea? |
I would suggest that the command should run within a SPFx project directory, similar to other |
@martinlingstuyl, @waldekmastykarz
|
ok second option I would recommend (I think even better then the first one) is yaml
what do you think? |
Ok, great, can we change the description a bit to make it a bit clearer? |
The docs for this command can also benefit from a good remarks section, I think... |
Seems a good choice! |
Absolutely, what would you add? |
Sure, what would you had in mind? |
Ok seems I got 2x✅ from @waldekmastykarz and @martinlingstuyl, right? The only things we now consider is more clarity in the spec or detail 🤔. |
The yaml package seems good on the surface: active, a group of contributors, regular releases. Let's try it! Good find! |
About the usage @Adam-it: We could also make it less specific:
We could later add extra types, like AzureDevOps... Just a brainwave |
This was actually made up on basecamp. The decision here is to support GH only for now as our CLI actions will only work for GH. As for Azure DevOps it has to be handled differently which actually would resolve in a totally different set of options. Due to that fact this command would be really hard to maintain, large, and would consist of lot of if else code blocks. Also pipeline I guess is more used in DevOps. In GH this is classified as workflow. So the name would also need to be different I guess 🤔. Maybe something like All in all I think it is a good suggestion to consider other solutions than just GH. But I am not sure if doing all in one command would be the way to go 🤔. At least in this particular case. |
I suggest that we use multiple commands, at least to start. Should we expand in the future, we can always revisit our stance. Since each CI system has different format of pipes, putting the different systems into one command could lead to too much unrelated code put into one command, not to mention different options required by each format. I suggest we start with GH and if we add other systems in the future, see if it makes sense to combine them or to keep them separate. |
Usage
m365 spfx project github workflow add [options]
Description
Adds a GitHub workflow for a SharePoint Framework project.
Options
-n, --name [name]
-b, --branchName [branchName]
-m, --manuallyTrigger
workflow_dispatch
-l, --loginMethod [loginMethod]
user
,application
. Defaultapplication
-s, --scope [scope]
tenant
,sitecollection
. Default istenant
--siteUrl [siteUrl]
sitecollection
--skipFeatureDeployment
--overwrite
Examples
Adds a GitHub workflow for a SharePoint Framework project with
application
login method triggered on push to mainAdds a GitHub workflow for a SharePoint Framework project with
user
login method triggered on push to main and when manually triggered.m365 spfx project github workflow add --manuallyTrigger --loginMethod "user"
Adds a GitHub workflow for a SharePoint Framework project with deployment to a site collection app catalog
Default properties
none
Additional Info
Remarks
When
loginMethod
option is used withuser
value then the CLI for Microsoft 365 login action will be created withADMIN_USERNAME
andADMIN_PASSWORD
. If theapplication
value will be used then the action will created withCERTIFICATE_ENCODED
,CERTIFICATE_PASSWORD
,APP_ID
.Example workflow
This is an example workflow that should be generated (without the comments 😉)
Implementation idea
How I would go about it is maybe keep a
.yml
file as part of the project in the command folder and just adjust it based on the options passed. We could have some markers inside the template.yml
file and just use plain replace based on what was specifiedFile
The command (like other
spfx
commands) should work within and SPFx project directory. On the root level of the SPFx project (so the same directory where package.json is present) the command should create a file with namedeploy.yml
and it should be created in.github/workflow/
subdirectories (the command should create those folders if not present).When a file with the same name already exist the command should present an error message.
Some other ideas
👉 I wasn't sure if it will be useful but CLI for Microsoft 365 actions also support specifying a CLI version that will be used and we may specify
latest
,next
or a specific version tag.👉 Also not sure if giving the possibility to specify a specific node version that will be used might be helpful. The latest version of SPFx supports v16.x but maybe someone would like to create a workflow for an older version of SPFx 🤔
👉 Another idea for an option would be if the bundle and package should be with
--ship
o not. Maybe someone would like a workflow that deploys a SPFx app for debuggingThe text was updated successfully, but these errors were encountered: