name: Prepare Release Oxlint

on:
  workflow_dispatch:
  push:
    branches:
      - trigger-other-workflow

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  pull-requests: write
  contents: write
  actions: write

jobs:
  prepare:
    name: Prepare Release Oxlint
    uses: ./.github/workflows/reusable_prepare_release.yml
    with:
      name: oxlint
    secrets:
      OXC_BOT_PAT : ${{ secrets.OXC_BOT_PAT }}

  ecosystem-ci:
    needs: prepare
    name: Trigger Ecosystem CI
    runs-on: ubuntu-latest
    steps:
      - uses: taiki-e/checkout-action@v1

      - uses: peter-evans/create-or-update-comment@v4
        id: comment
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          issue-number: ${{ needs.prepare.outputs.pull-request-number }}
          body: Triggering Ecosystem CI https://github.com/oxc-project/oxlint-ecosystem-ci/actions/workflows/ecosystem-ci.yml

      - uses: benc-uk/workflow-dispatch@v1
        with:
          repo: oxc-project/oxlint-ecosystem-ci
          workflow: ecosystem-ci.yml
          token: ${{ secrets.PAT }}
          ref: main
          inputs: '{ "issue-number": "${{ needs.prepare.outputs.pull-request-number }}", "comment-id": "${{ steps.comment.outputs.comment-id }}" }'

  website:
    needs: prepare
    name: Update oxc.rs
    runs-on: ubuntu-latest
    steps:
      - uses: taiki-e/checkout-action@v1
      - uses: benc-uk/workflow-dispatch@v1
        with:
          repo: oxc-project/oxc-project.github.io
          workflow: release.yml
          token: ${{ secrets.PAT }}
          ref: main
          inputs: '{ "issue-number": "${{ needs.prepare.outputs.pull-request-number }}", "version": "${{ needs.prepare.outputs.version }}" }'
