name: "Update Jetbrains plugins"
on:
  schedule:
    - cron: '00 2 * * *'

jobs:
  tests:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v2.3.3
    - name: Install nix
      uses: cachix/install-nix-action@v11
      with:
        nix_path: "${{ matrix.nixPath }}"
    - name: Show nixpkgs version
      run: nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'
    - name: Generate package list
      # TODO switch to default nixpkgs channel once nix-build-uncached 1.0.0 is in stable
      run: nix run -I 'nixpkgs=channel:nixos-unstable' nixpkgs.nix-build-uncached -c nix-build-uncached ci.nix -A cacheOutputs
    - name: Trigger NUR update
      if: ${{ matrix.nurRepo != '<YOUR_REPO_NAME>' }}
      run: curl -XPOST "https://nur-update.herokuapp.com/update?repo=${{ matrix.nurRepo }}"