# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- dev

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- checkout: self
  persistCredentials: true

- script: |
    cd microsoft-authentication-library-for-js
    npm install
    npm run build
  displayName: 'npm install and build'

- task: CmdLine@2
  inputs:
    script: |
      cd microsoft-authentication-library-for-js
      
      git subtree split --prefix lib/msal-browser -b msal-browser-latest
      
      git push -u origin msal-browser-latest

- task: CmdLine@2
  inputs:
    script: |
      cd microsoft-authentication-library-for-js
      
      git subtree split --prefix lib/msal-common -b msal-common-latest
      
      git push -u origin msal-common-latest

- checkout: git://IDDP/msal-javascript-1p
  persistCredentials: true

- task: CmdLine@2
  inputs:
    script: |
      cd msal-js-test

      git config --global user.email "msaljs@microsoft.com"
      git config --global user.name "MSAL CI"

      git checkout master
      
      git subtree pull --prefix msal-browser https://github.com/azuread/microsoft-authentication-library-for-js.git msal-browser-latest
      
      git subtree pull --prefix msal-common https://github.com/azuread/microsoft-authentication-library-for-js.git msal-common-latest

      git add .
      
      git commit -m "Latest build"
      
      git push -u origin master

Set up CI with Azure Pipelines
Set up CI with Azure Pipelines

[skip ci]