name: Build at pull request

on:
  workflow_dispatch:
  pull_request:
    types: [review_requested, ready_for_review]
    paths-ignore:
      - .github/workflows

jobs:

  Check:
    name: Checking
    if: ${{ success() && github.repository_owner == 'Armbian' }}
    uses: armbian/scripts/.github/workflows/check-for-changes.yml@master

  Build:
    needs: Check
    if: ${{ success() && github.repository_owner == 'Armbian' }}
    uses: armbian/scripts/.github/workflows/build-kernel.yml@master

    with:

      uploading: "false"
      runner: "fast"
      reference: ${{ github.event.pull_request.head.sha }}

    secrets:
      GPG_KEY1: ${{ secrets.GPG_KEY1 }}
      GPG_PASSPHRASE1: ${{ secrets.GPG_PASSPHRASE1 }}
      GPG_KEY2: ${{ secrets.GPG_KEY2 }}
      GPG_PASSPHRASE2: ${{ secrets.GPG_PASSPHRASE2 }}
      SCRIPTS_ACCESS_TOKEN: ${{ secrets.SCRIPTS_ACCESS_TOKEN }}
      KEY_TORRENTS: ${{ secrets.KEY_TORRENTS }}
      KNOWN_HOSTS_UPLOAD: ${{ secrets.KNOWN_HOSTS_UPLOAD }}

  jobsend:
    name: Cleanup
    needs: [Build]
    runs-on: "small"
    if: ${{ github.repository_owner == 'Armbian' }}
    steps:
      - uses: geekyeggo/delete-artifact@v1
        with:
          name: changes
      - uses: geekyeggo/delete-artifact@v1
        with:
          name: hash
