You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -33,10 +33,25 @@ When connecting to any system or service, we need to make sure that the account
33
33
34
34
First you will need to need to navigate, in your browser, to your repository on GitHub.com and go to the `Settings` tab, from here choose the `Secrets` item on the left hand menu.
35
35
36
-
Using the `Add new secret` link, enter the `ADMIN_USERNAME` into the `Name` field and the username of the account that you are to use to connect to your Microsoft 365 tenant with, e.g. `[email protected]`. *Note: This account should not be protected with multi factor authentication*
36
+
You may have two options when registering secrets in order to log in to your tenant:
37
+
38
+
* Using username / password (perfect to test your workflow, in a dev context, for personal usage) ==> **delegated secrets**
39
+
**In that case, the CLI commands will run as if it was you (list item updates, site creation...)*
40
+
* Using Azure AD (AAD) application id / certificate (perfect in a production context, without creating any dependencies to an account) ==> **application secrets**
41
+
**Here, the CLI commands will run through an app, not a user*
42
+
43
+
##### Delegated secrets
44
+
45
+
Using the `Add new secret` link, enter the `ADMIN_USERNAME` into the `Name` field and the username of the account that you are to use to connect to your Microsoft 365 tenant with, e.g. `[email protected]`. *Note: This account should not be protected with multi-factor authentication*
37
46
38
47
Repeat the above step to also store the account password which should be named `ADMIN_PASSWORD`.
39
48
49
+
##### Application secrets
50
+
51
+
Using the `Add new secret` link, enter the `APP_ID` into the `Name` field and the (client) id of the AAD application to connect to your Microsoft 365 tenant with, e.g. `d355e6f0-0aec-4b1f-b458-7040f91bc297`.
52
+
53
+
Repeat the above step to also store the application's encoded certificate which should be named `CERTIFICATE_ENCODED`. If your certificate is encrypted with a password, then repeat one last time the previous step with a secret called `CERTIFICATE_PASSWORD`.
54
+
40
55
#### Setup workflow
41
56
42
57
Now that we have secured the account credentials, we can start to create the workflow.
@@ -73,28 +88,52 @@ The above configuration defines a simple workflow named `CI` that is triggered o
73
88
74
89
We will update the initial configuration as shown below, replacing the existing steps with the `CLI for Microsoft 365 Login` action instead.
The `uses` property tells the build agent to use the `CLI for Microsoft 365` GitHub Action for the step, this will automatically become available when the workflow is triggered, no installation is required.
96
135
97
-
The action accepts an admin username and password, which are used to authenticate with your Microsoft 365 tenant, these credentials are provided by an environment variable called `secrets` which contains properties exposing the secured credentials that we saved earlier.
136
+
The action accepts an admin username and password (or an application id / encoded certificate), which are used to authenticate with your Microsoft 365 tenant, these credentials are provided by an environment variable called `secrets` which contains properties exposing the secured credentials that we saved earlier.
98
137
99
138
Lastly, we need to commit the `main.yaml` file to the repository, click the `Start Commit` button and click `Commit new file`. You may want enter a custom commit message at this point, however the default will be fine for this tutorial.
100
139
@@ -110,6 +149,60 @@ Congratulations! You have just setup your first custom workflow in a GitHub repo
Sometimes, you would like to use the next (beta) version or a previous one of the CLI (because of a bug that is currently being addressed or to leverage a new feature to come).
155
+
156
+
The `CLI for Microsoft 365 Login` action provides an optional input to specify a version tag which can be `latest` (default if not specified), `next` or a specific one (`5.9.0`).
Depending on the context, you could have to specify the tenant id if you have access to multiple tenants.
182
+
183
+
The `CLI for Microsoft 365 Login` allows you to indicate the targeting tenant (default `common`). It can be `organization` (if using an Azure AD app which is multitenant) or a tenant id.
run: echo "The id of the app deployed is ${{ steps.o365clideploy.outputs.APP_ID }}"
254
+
run: echo "The id of the app deployed is ${{ steps.M365clideploy.outputs.APP_ID }}"
161
255
```
162
256
163
257
Alternatively, you can deploy the app to a site collection based app catalog by using the below step in replacement of the `Deploy app to tenant app catalog` step.
164
258
165
259
```yaml
166
260
- name: Deploy app to a site collection app catalog
@@ -178,9 +272,9 @@ Add this step to a `.yaml` build file contained within the `.github/workflows` f
178
272
179
273
```yaml
180
274
- name: Send email
181
-
uses: pnp/action-cli-runscript@v1.0.0
275
+
uses: pnp/action-cli-runscript@v2.0.1
182
276
with:
183
-
O365_CLI_SCRIPT: m365 spo mail send --webUrl https://contoso.sharepoint.com/sites/teamsite --to '[email protected]' --subject 'Deployment done' --body '<h2>CLI for Microsoft 365</h2> <p>The deployment is complete.</p> <br/> Email sent via CLI for Microsoft 365 GitHub Action.'
277
+
M365_CLI_SCRIPT: m365 spo mail send --webUrl https://contoso.sharepoint.com/sites/teamsite --to '[email protected]' --subject 'Deployment done' --body '<h2>CLI for Microsoft 365</h2> <p>The deployment is complete.</p> <br/> Email sent via CLI for Microsoft 365 GitHub Action.'
184
278
```
185
279
186
280
### Execute a script file using the CLI for Microsoft 365 Run Script action
@@ -189,9 +283,9 @@ Add the respective script file to your repository and this step to a `.yaml` bui
189
283
190
284
```yaml
191
285
- name: Create lists
192
-
uses: pnp/action-cli-runscript@v1.0.0
286
+
uses: pnp/action-cli-runscript@v2.0.1
193
287
with:
194
-
O365_CLI_SCRIPT_PATH: ./script/lists.ps1
288
+
M365_CLI_SCRIPT_PATH: ./script/lists.ps1
195
289
```
196
290
197
291
## Reference
@@ -202,10 +296,15 @@ View on [GitHub Marketplace](https://github.com/marketplace/actions/cli-for-micr
| `O365_CLI_SCRIPT_PATH` | Relative path to the script | Required |
237
-
| `O365_CLI_SCRIPT` | The script to run | Required |
238
-
| `IS_POWERSHELL` | Used only with `O365_CLI_SCRIPT`. If `true`, `O365_CLI_SCRIPT` will be passed as a PowerShell script, otherwise the assumption is `bash` script. Default is `false` | Optional |
335
+
| `M365_CLI_SCRIPT_PATH` | Relative path to the script | Required |
336
+
| `M365_CLI_SCRIPT` | The script to run | Required |
337
+
| `IS_POWERSHELL` | Used only with `M365_CLI_SCRIPT`. If `true`, `M365_CLI_SCRIPT` will be passed as a PowerShell script, otherwise the assumption is `bash` script. Default is `false` | Optional |
239
338
240
339
!!! attention
241
-
One of `O365_CLI_SCRIPT_PATH` / `O365_CLI_SCRIPT` is mandatory, in case both are defined `O365_CLI_SCRIPT_PATH` gets preference.
340
+
One of `M365_CLI_SCRIPT_PATH` / `M365_CLI_SCRIPT` is mandatory, in case both are defined `M365_CLI_SCRIPT_PATH` gets preference.
0 commit comments