name: Rootfs Caches

on:
  workflow_dispatch:
    inputs:

      branch:
        description: 'Build branch to use'
        required: true
        default: 'nightly'

jobs:

  merge:
    uses: armbian/scripts/.github/workflows/merge-from-branch.yml@master

    with:
      branch: 'nightly'
      runner: small

    secrets:  
      GPG_KEY2: ${{ secrets.GPG_KEY2 }}
      GPG_PASSPHRASE2: ${{ secrets.GPG_PASSPHRASE2 }}

  armhf:
    needs: [ merge ]
    uses: armbian/scripts/.github/workflows/build-rootfs-cache.yml@master

    with:
      rootfsarch: 'bananapi'
      runner: 'small'
      branch: ${{ github.event.inputs.branch }}

    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 }}

  aarch64:
    needs: [ merge ]
    uses: armbian/scripts/.github/workflows/build-rootfs-cache.yml@master

    with:
      rootfsarch: 'lepotato'
      runner: 'small'
      branch: ${{ github.event.inputs.branch }}

    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 }}

  amd64:
    needs: [ merge ]
    uses: armbian/scripts/.github/workflows/build-rootfs-cache.yml@master
    with:

      rootfsarch: 'uefi-x86'
      runner: 'x64'
      branch: ${{ github.event.inputs.branch }}

    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 }}

  jobsend:
    name: finish
    needs: [armhf,aarch64,amd64]
    runs-on: [ubuntu-latest]
    if: ${{ github.repository_owner == 'Armbian' }}
    steps:
      - run: |
          echo "End"
