name: "\U0001F680 Deploy mobile production OTA update"

on:
  workflow_dispatch:

jobs:
  deploy_production_ota:
    name: "\U0001F680 Deploy production OTA update"
    runs-on: ubuntu-latest
    env:
      working-directory: ./apps/mobile
    steps:
      - uses: actions/checkout@v6
        with:
          ref: ${{ github.event.pull_request.head.sha }}
          fetch-depth: 0
      - uses: actions/setup-node@v6
        with:
          node-version: 24
      - uses: pnpm/action-setup@v4
      - name: "\U0001F3D7 Expose git commit data"
        uses: jcputney/git-commit-data-action@v2
      - name: "\U0001F4E6 Install Packages"
        run: pnpm install --frozen-lockfile
        working-directory: ${{ env.working-directory }}
      - name: Generate dotenv file
        working-directory: ${{ env.working-directory }}
        env:
          environ: '{"EXPO_PUBLIC_NODE_ENV": "production"}'
        run: |
          ../../.github/scripts/create-env.sh "$environ"
      - uses: expo/expo-github-action@v8
        with:
          expo-cache: true
          expo-version: latest
          eas-version: latest
          token: ${{ secrets.EXPO_TOKEN }}
      - name: "\U0001F3D7 Extract version number"
        shell: bash
        run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
        id: extract_version_number
      - name: "\U0001F680 Deploy production OTA update"
        run: |
          eas update -p ios --branch production --message "${{ steps.extract_version_number.outputs.version }}" --non-interactive
          eas update -p android --branch production --message "${{ steps.extract_version_number.outputs.version }}" --non-interactive
        working-directory: ${{ env.working-directory }}
