Skip to content

Commit 07148ad

Browse files
anooptVelinGeorgiev
authored andcommitted
Added 'Office 365 CLI deploy' GitHub action solving #2
1 parent 0b34ce9 commit 07148ad

File tree

10 files changed

+2311
-1
lines changed

10 files changed

+2311
-1
lines changed

.gitignore

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# comment out in distribution branches
2+
node_modules/
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# Diagnostic reports (https://nodejs.org/api/report.html)
14+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15+
16+
# Runtime data
17+
pids
18+
*.pid
19+
*.seed
20+
*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
lib-cov
24+
25+
# Coverage directory used by tools like istanbul
26+
coverage
27+
*.lcov
28+
29+
# nyc test coverage
30+
.nyc_output
31+
32+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33+
.grunt
34+
35+
# Bower dependency directory (https://bower.io/)
36+
bower_components
37+
38+
# node-waf configuration
39+
.lock-wscript
40+
41+
# Compiled binary addons (https://nodejs.org/api/addons.html)
42+
build/Release
43+
44+
# Dependency directories
45+
jspm_packages/
46+
47+
# TypeScript v1 declaration files
48+
typings/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional REPL history
60+
.node_repl_history
61+
62+
# Output of 'npm pack'
63+
*.tgz
64+
65+
# Yarn Integrity file
66+
.yarn-integrity
67+
68+
# dotenv environment variables file
69+
.env
70+
.env.test
71+
72+
# parcel-bundler cache (https://parceljs.org/)
73+
.cache
74+
75+
# next.js build output
76+
.next
77+
78+
# nuxt.js build output
79+
.nuxt
80+
81+
# vuepress build output
82+
.vuepress/dist
83+
84+
# Serverless directories
85+
.serverless/
86+
87+
# FuseBox cache
88+
.fusebox/
89+
90+
# DynamoDB Local files
91+
.dynamodb/

README.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,100 @@
1-
# action-cli-deploy
1+
# Office 365 CLI deploy GitHub action
22
GitHub action to deploy an app using Office 365 CLI
3+
4+
![Office 365 CLI Deploy App](./images/cli-deploy.png)
5+
6+
This GitHub Action (created using typescript) uses [Office 365 CLI](https://pnp.github.io/office365-cli/), specifically the [spo app add](https://pnp.github.io/office365-cli/cmd/spo/app/app-add/), [spo app deploy](https://pnp.github.io/office365-cli/cmd/spo/app/app-deploy/) and [spo app install](https://pnp.github.io/office365-cli/cmd/spo/app/app-install/) commands, to add, deploy and (if site collection) install an app.
7+
8+
## Usage
9+
### Pre-requisites
10+
Create a workflow `.yml` file in your `.github/workflows` directory. An [example workflow](#example-workflow---office-365-cli-deploy) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
11+
12+
## Dependencies on other GitHub Actions
13+
14+
- [Office 365 CLI Login](https://github.com/pnp/action-cli-login)**Required** . This action is dependant on `action-cli-login`. So in the workflow we need to run `action-cli-login` before using this action.
15+
16+
#### Optional requirement
17+
Since `action-cli-login` requires user name and password which are sensitive pieces of information, it would be ideal to store them securely. We can achieve this in a GitHub repo by using [secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets). So, click on `settings` tab in your repo and add 2 new secrets:
18+
- `adminUsername` - store the admin user name in this (e.g. user@contoso.onmicrosoft.com)
19+
- `adminPassword` - store the password of that user in this.
20+
These secrets are encrypted and can only be used by GitHub actions.
21+
22+
### Inputs
23+
- `APP_FILE_PATH` : **Required** Relative path of the app in your repo
24+
- `SCOPE` : Scope of the app catalog: `tenant|sitecollection`. Default is `tenant`
25+
- `SITE_COLLECTION_URL` : The URL of the site collection where the solution package will be added and installed. Required if scope is set to `sitecollection`
26+
- `SKIP_FEATURE_DEPLOYMENT` : `true|false` If the app supports tenant-wide deployment, deploy it to the whole tenant. Default is `false`
27+
- `OVERWRITE` : `true|false` Set to overwrite the existing package file. Default is `false`
28+
29+
### Output
30+
- `APP_ID` : The id of the app that gets deployed
31+
32+
### Example workflow - Office 365 CLI Deploy
33+
On every `push` build the code, then login to Office 365 and then start deploying.
34+
35+
```yaml
36+
name: SPFx CICD with O365 CLI
37+
38+
on: [push]
39+
40+
jobs:
41+
build:
42+
##
43+
## Build code omitted
44+
##
45+
46+
deploy:
47+
needs: build
48+
runs-on: ubuntu-latest
49+
strategy:
50+
matrix:
51+
node-version: [10.x]
52+
53+
steps:
54+
55+
##
56+
## Code to get the package omitted
57+
##
58+
59+
# Office 365 cli login action
60+
- name: Login to tenant
61+
uses: pnp/action-cli-login@v1.0.0
62+
with:
63+
ADMIN_USERNAME: ${{ secrets.adminUsername }}
64+
ADMIN_PASSWORD: ${{ secrets.adminPassword }}
65+
66+
# Office 365 cli deploy app action
67+
# Use either option 1 or option 2
68+
69+
# Option 1 - Deploy app at tenant level
70+
- name: Option 1 - Deploy app to tenant
71+
id: o365clideploy # optional - use if output needs to be used
72+
uses: pnp/action-cli-deploy@v1.0.0
73+
with:
74+
APP_FILE_PATH: sharepoint/solution/spfx-o365-cli-action.sppkg
75+
SKIP_FEATURE_DEPLOYMENT: true
76+
OVERWRITE: true
77+
# Option 1 - ends
78+
79+
# Option 2 - Deploy app to a site collection
80+
- name: Option 2 - Deploy app to a site collection
81+
uses: pnp/action-cli-deploy@v1.0.0
82+
with:
83+
APP_FILE_PATH: sharepoint/solution/spfx-o365-cli-action.sppkg
84+
SCOPE: sitecollection
85+
SITE_COLLECTION_URL: https://contoso.sharepoint.com/sites/teamsite
86+
# Option 2 - ends
87+
88+
# Print the id of the app
89+
- name: Get the id of the app deployed
90+
run: echo "The id of the app deployed is ${{ steps.o365clideploy.outputs.APP_ID }}"
91+
```
92+
93+
94+
#### Self-hosted runners
95+
If self-hosted runners are used for running the workflow, then please make sure that they have `PowerShell` or `bash` installed on them.
96+
97+
## Release notes
98+
99+
### v1.0.0
100+
- Added inital 'Office 365 CLI deploy' GitHub action solving #2

action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Office 365 CLI Deploy App'
2+
description: 'Deploy an app using Office 365 CLI'
3+
inputs:
4+
APP_FILE_PATH:
5+
description: 'Relative path of the app in your repo'
6+
required: true
7+
SCOPE:
8+
description: 'Scope of the app catalog: tenant or sitecollection. Default is tenant'
9+
SITE_COLLECTION_URL:
10+
description: 'The URL of the site collection where the solution package will be added and installed. Required if scope is set to sitecollection'
11+
SKIP_FEATURE_DEPLOYMENT:
12+
description: 'True or false. If the app supports tenant-wide deployment, deploy it to the whole tenant. Default is false'
13+
OVERWRITE:
14+
description: 'True or false. Set to overwrite the existing package file. Default is false'
15+
output:
16+
APP_ID:
17+
description: 'The Id of the app that gets deployed'
18+
runs:
19+
using: "node12"
20+
main: "dist/index.js"
21+
branding:
22+
icon: 'download'
23+
color: 'blue'

0 commit comments

Comments
 (0)