name: Shorebird Patch

on:
  workflow_dispatch:
    inputs:
      version_to_patch:
        description: 'Version to patch: format: 1.0.0+7'
        type: string
jobs:
  shorebird_patch:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: 🐦 Setup Shorebird
        uses: shorebirdtech/setup-shorebird@v1
      - name: Create Patch
        env:
          SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
          SIGNING_KEYSTORE_BASE64: ${{ secrets.SIGNING_KEYSTORE_BASE64 }}
          SIGNING_PROPERTIES: ${{ secrets.SIGNING_PROPERTIES }}
        run: |
          echo "$SIGNING_KEYSTORE_BASE64" | base64 --decode > android/app/experiment.jks
          echo "$SIGNING_PROPERTIES" > android/signing.properties
          echo y | shorebird patch --platforms=android --release-version=${{ github.event.inputs.version_to_patch }}