name: Convert CHANGELOG to Fastlane

on:
  workflow_dispatch:
  push:
    branches:
      - main
    paths:
      - 'CHANGELOG.md'

permissions:
  contents: write
  pull-requests: write

jobs:
  convert_changelog_to_fastlane:
    runs-on: ubuntu-latest
    name: Convert CHANGELOG to Fastlane
    steps:
    - name: Checkout repo
      id: checkout
      uses: actions/checkout@v7.0.0
    - name: Setup Python
      uses: actions/setup-python@v6.3.0
      with:
        python-version: '3.x'
    - name: Run converter script
      run: python .scripts/changelog_to_fastlane.py
    - name: Create Pull Request
      uses: peter-evans/create-pull-request@v8.1.1
      with:
        title: "Update Fastlane changelogs"
        commit-message: "Update Fastlane changelogs"
        branch-suffix: timestamp
