# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Cancel Previous Redundant Builds
      uses: styfle/cancel-workflow-action@0.6.0
      with:
        access_token: ${{ github.token }}
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
        persist-credentials: false
    - uses: actions/setup-node@v1
      with:
        node-version: 14
        registry-url: 'https://registry.npmjs.org'
    - run: npm run phoenix:ci
    - run: npm run lint
    - run: npm run test:ci
    - run: npx @s-ui/ci release
      env:
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
        DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
        GITHUB_EMAIL: cloud-accounts@scmspain.com
        GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_TOKEN }}
        GITHUB_USER: sui-bot
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
