|
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 | + |
| 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 |
0 commit comments