name: Automatic Build and Deploy

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: macos-15
    name: Build IOS
    steps:
      - uses: actions/checkout@v2
        name: Check out repository
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - run: |
          bun i && bun run submodule-reload
          npx expo prebuild
      - uses: sparkfabrik/ios-build-action@v2.3.0
        with:
          upload-to-testflight: false
          increment-build-number: false
          build-pods: true
          pods-path: "ios/Podfile"
          configuration: Release
          # Change later to app-store if wanted
          export-method: appstore
          #export-method: ad-hoc
          workspace-path: "ios/Streamyfin.xcodeproj/project.xcworkspace/"
          project-path: "ios/Streamyfin.xcodeproj"
          scheme: Streamyfin
          apple-key-id: ${{ secrets.APPLE_KEY_ID }}
          apple-key-issuer-id: ${{ secrets.APPLE_KEY_ISSUER_ID }}
          apple-key-content: ${{ secrets.APPLE_KEY_CONTENT }}
          team-id: ${{ secrets.TEAM_ID }}
          team-name: ${{ secrets.TEAM_NAME }}
          #match-password: ${{ secrets.MATCH_PASSWORD }}
          #match-git-url: ${{ secrets.MATCH_GIT_URL }}
          #match-git-basic-authorization: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
          #match-build-type: "appstore"
          #browserstack-upload: true
          #browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }}
          #browserstack-access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
          #fastlane-env: stage
          ios-app-id: com.stetsed.teststreamyfin
          output-path: build-${{ github.sha }}.ipa
