name: simulate-deployment
on:
  push:
    branches: ['feature/update-deploy']

  workflow_dispatch:

jobs:
  simulate-deployment:
    runs-on: ubuntu-latest

    env:
      SB2_ACCOUNT_ID: ${{ secrets.SB2_ACCOUNT_ID }}
      SB2_TOKEN_ID: ${{ secrets.SB2_TOKEN_ID }}
      SB2_TOKEN_SECRET: ${{ secrets.SB2_TOKEN_SECRET }}

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1

      # Fetch the master branch so we can compare it with the current branch
      - run: git fetch origin master:master

      # Install the SuiteCloud CLI
      - run: npm install -g @oracle/suitecloud-cli

      # Install our dependencies
      - run: npm install

      # Compare current branch to master and update the deploy.xml file
      - run: npm run update-deployment

      # Get a token to use for deployment
      - run: npm run netsuite:savetoken

      # Add any missing dependencies for the current deployment
      - run: npm run netsuite:adddependencies

      # Perform deployment.  Output should be shown in the GitHub action
      - run: npm run netsuite:deploy
