name: appdistribution

permissions:
  contents: read

on:
  workflow_dispatch:
  pull_request:
    paths:
    - 'FirebaseAppDistribution**'
    - '.github/workflows/appdistribution.yml'
    - '.github/workflows/common.yml'
    - '.github/workflows/common_cocoapods.yml'
    - '.github/workflows/common_catalyst.yml'
    - '.github/workflows/common_cocoapods_cron.yml'
    - 'Gemfile*'
  schedule:
    # Run every day at 2am (PDT) / 5am (EDT) - cron uses UTC times
    - cron: '0 9 * * *'

concurrency:
    group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
    cancel-in-progress: true

jobs:
  spm:
    uses: ./.github/workflows/common.yml
    with:
      target: AppDistributionUnit
      platforms: iOS

  catalyst:
    uses: ./.github/workflows/common_catalyst.yml
    with:
      product: FirebaseAppDistribution
      target: FirebaseAppDistribution-Unit-unit

  pod_lib_lint:
    uses: ./.github/workflows/common_cocoapods.yml
    with:
      product: FirebaseAppDistribution
      platforms: iOS # App Distro only supports iOS.

  appdistribution-cron-only:
    needs: pod_lib_lint
    uses: ./.github/workflows/common_cocoapods_cron.yml
    with:
      product: FirebaseAppDistribution
      platforms: '[ "ios" ]'
      flags: '[ "--use-static-frameworks" ]'
