name: Publish OTA updates

on:
  push:
    branches: ['main']
    paths:
      - 'app/**'
      - 'components/**'
      - 'hooks/**'
      - 'lib/**'
      - 'types/**'
      - 'assets/**'
      - 'App.tsx'
      - 'index.ts'
      - 'global.css'
      - 'tailwind.config.js'
      - 'babel.config.js'
      - 'metro.config.js'
  workflow_dispatch:
    inputs:
      channel:
        type: choice
        description: Update channel to publish.
        default: production
        options:
          - preview
          - production
      environment:
        type: choice
        description: EAS environment to use for the update job.
        default: production
        options:
          - preview
          - production
      message:
        description: Optional update message override.
        required: false

jobs:
  publish_main:
    if: ${{ github.event_name == 'push' }}
    name: Publish production update
    type: update
    environment: production
    params:
      channel: production
      platform: all

  publish_manual:
    if: ${{ github.event_name == 'workflow_dispatch' }}
    name: Publish selected update
    type: update
    environment: ${{ inputs.environment }}
    params:
      channel: ${{ inputs.channel }}
      message: ${{ inputs.message }}
      platform: all
