Coder Social home page Coder Social logo

jwaegebaert / action-cli-deploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pnp/action-cli-deploy

0.0 0.0 0.0 248 KB

GitHub action to deploy an app using CLI for Microsoft 365

Home Page: https://aka.ms/cli-m365

License: MIT License

TypeScript 100.00%

action-cli-deploy's Introduction

CLI for Microsoft 365 Deploy

GitHub action to deploy an app using CLI for Microsoft 365

CLI for Microsoft 365 Deploy App

This GitHub Action (created using typescript) uses CLI for Microsoft 365, specifically the spo app add, spo app deploy commands, to add and deploy.

Usage

Pre-requisites

Create a workflow .yml file in your .github/workflows directory. An example workflow is available below. For more information, reference the GitHub Help Documentation for Creating a workflow file.

Dependencies on other GitHub Actions

  • CLI for Microsoft 365 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.

Optional requirement

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. So, click on settings tab in your repo and add 2 new secrets:

  • ADMIN_USERNAME - store the admin user name in this (e.g. [email protected])
  • ADMIN_PASSWORD - store the password of that user in this.

These secrets are encrypted and can only be used by GitHub actions.

Compatibility matrix

The following table lists which versions of the GitHub action are compatible with which versions of the CLI for Microsoft 365.

Version CLI for Microsoft 365 version
^v3.0.0 v6.0.0
v2.0.2 v5.8.0
v1.0.0 v2.5.0

Inputs

  • APP_FILE_PATH : Required Relative path of the app in your repo
  • SCOPE : Scope of the app catalog: tenant|sitecollection. Default is tenant
  • SITE_COLLECTION_URL : The URL of the site collection where the solution package will be added. Required if scope is set to sitecollection
  • SKIP_FEATURE_DEPLOYMENT : true|false If the app supports tenant-wide deployment, deploy it to the whole tenant. Default is false
  • OVERWRITE : true|false Set to overwrite the existing package file. Default is false

Output

  • APP_ID : The id of the app that gets deployed

Example workflow - CLI for Microsoft 365 Deploy

On every push build the code, then login to Office 365 and then start deploying.

name: SPFx CICD with CLI for Microsoft 365

on: [push]

jobs:
  build:
    ##
    ## Build code omitted
    ##
        
  deploy:
    needs: build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18.x]
    
    steps:
    
    ##
    ## Code to get the package omitted
    ##

    # CLI for Microsoft 365 login action
    - name: Login to tenant
      uses: pnp/action-cli-login@v2
      with:
        ADMIN_USERNAME:  ${{ secrets.ADMIN_USERNAME }}
        ADMIN_PASSWORD:  ${{ secrets.ADMIN_PASSWORD }}
    
    # CLI for Microsoft 365 deploy app action
    # Use either option 1 or option 2
    
    # Option 1 - Deploy app at tenant level
    - name: Option 1 - Deploy app to tenant
      id: climicrosoft365deploy # optional - use if output needs to be used
      uses: pnp/action-cli-deploy@v4
      with:
        APP_FILE_PATH: sharepoint/solution/spfx-cli-microsoft365-action.sppkg
        SKIP_FEATURE_DEPLOYMENT: true
        OVERWRITE: true
    # Option 1 - ends
     
    # Option 2 - Deploy app to a site collection
    - name: Option 2 - Deploy app to a site collection
      uses: pnp/action-cli-deploy@v4
      with:
        APP_FILE_PATH: sharepoint/solution/spfx-cli-microsoft365-action.sppkg
        SCOPE: sitecollection
        SITE_COLLECTION_URL: https://contoso.sharepoint.com/sites/teamsite
    # Option 2 - ends

    # Print the id of the app
    - name: Get the id of the app deployed
      run: echo "The id of the app deployed is ${{ steps.climicrosoft365deploy.outputs.APP_ID }}"

Self-hosted runners

If self-hosted runners are used for running the workflow, then please make sure that they have PowerShell or bash installed on them.

action-cli-deploy's People

Contributors

anoopt avatar garrytrinder avatar jwaegebaert avatar martinlingstuyl avatar milanholemans avatar velingeorgiev avatar waldekmastykarz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.