Skip to content

Commit c8c75ea

Browse files
anooptVelinGeorgiev
authored andcommitted
Added 'Office 365 CLI login' GitHub action solving #2
1 parent 107a23a commit c8c75ea

File tree

10 files changed

+2235
-2
lines changed

10 files changed

+2235
-2
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: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,67 @@
1-
# action-cli-login
2-
GitHub action to login to a tenant using Office 365 CLI
1+
# Office 365 CLI login GitHub action
2+
GitHub action to login to a tenant using Office 365 CLI.
3+
4+
![Office 365 CLI Login](./images/cli-login.png)
5+
6+
This GitHub Action (created using typescript) uses [Office 365 CLI](https://pnp.github.io/office365-cli/), specifically the [login command](https://pnp.github.io/office365-cli/cmd/login), to allow you log in to Office 365.
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-login) 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+
### Inputs
13+
- `ADMIN_USERNAME` : **Required** Username (email address of the admin)
14+
- `ADMIN_PASSWORD` : **Required** Password of the admin
15+
16+
#### Optional requirement
17+
Since this action 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+
### Example workflow - Office 365 CLI Login
23+
On every `push` build the code and then login to Office 365 before deploying.
24+
25+
```yaml
26+
name: SPFx CICD with O365 CLI
27+
28+
on: [push]
29+
30+
jobs:
31+
build:
32+
##
33+
## Build code omitted
34+
##
35+
36+
deploy:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
node-version: [10.x]
42+
43+
steps:
44+
45+
##
46+
## Code to get the package omitted
47+
##
48+
49+
# Office 365 cli login action
50+
- name: Login to tenant
51+
uses: pnp/action-cli-login@v1.0.0
52+
with:
53+
ADMIN_USERNAME: ${{ secrets.adminUsername }}
54+
ADMIN_PASSWORD: ${{ secrets.adminPassword }}
55+
56+
##
57+
## Code to deploy the package to tenant omitted
58+
##
59+
```
60+
61+
#### Self-hosted runners
62+
If self-hosted runners are used for running the workflow, then please make sure that they have `PowerShell` or `bash` installed on them.
63+
64+
## Release notes
65+
66+
### v1.0.0
67+
- Added inital 'Office 365 CLI login' GitHub action solving #2

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'Office 365 CLI Login'
2+
description: 'Login to tenant using Office 365 CLI'
3+
inputs:
4+
ADMIN_USERNAME:
5+
description: 'Username (email address) of the admin'
6+
required: true
7+
ADMIN_PASSWORD:
8+
description: 'Password of the admin'
9+
required: true
10+
runs:
11+
using: "node12"
12+
main: "dist/index.js"
13+
branding:
14+
icon: 'log-in'
15+
color: 'blue'

0 commit comments

Comments
 (0)