name: Update Electon vendors versions
on:
  push:
    branches:
      - main
    paths:
      - 'package-lock.json'


concurrency:
  group: update-electron-vendors-${{ github.ref }}
  cancel-in-progress: true


defaults:
  run:
    shell: 'bash'


jobs:
  node-chrome:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16 # Need for npm >=7.7
          cache: 'npm'

      # TODO: Install not all dependencies, but only those required for this workflow
      - name: Install dependencies
        run: npm ci

      - run: node ./scripts/update-electron-vendors.js

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        with:
          delete-branch: true
          commit-message: Update electron vendors
          branch: autoupdates/electron-vendors
          title: Update electron vendors
          body: Updated versions of electron vendors in `electron-vendors.config.json` and `.browserslistrc` files
