name: CI
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  build:
    name: 1. BUILD
    runs-on: ubuntu
    env:
      VERSION: "0.0.0-beta.${{ gitea.run_number }}"
    steps:
    - name: Publishing Release
      uses: akkuman/gitea-release-action@${{ vars.ACTION_GITEA_RELEASE_VERSION }}
      with:
        name: "${{ gitea.event.repository.name }} v${{ env.VERSION }}"
        tag_name: "v${{ env.VERSION }}"
        target_commitish: ${{ gitea.sha }}
        prerelease: ${{ gitea.base_ref == 'develop' }}
  test:
    name: 2. TEST
    runs-on: ubuntu
    needs: [build]
    outputs:
      message: ${{ steps.composite-template.outputs.message }}
    steps:
    - name: Setup LLM CLI
      uses: https://gitea.jsc.idv.tw/actions/setup-${{ vars.ACTION_SETUP_LLM_CLI }}
      with:
        oauth: ${{ secrets.LLM_OAUTH }}
    - name: Run AI Code Review
      id: ai-code-review
      uses: https://gitea.jsc.idv.tw/actions/ai-code-review@v${{ env.VERSION }}
      with:
        token: ${{ secrets.TOKEN }}
        model: ${{ vars.LLM_NAME }}
  result:
    name: 3. RESULT
    runs-on: ubuntu
    needs: [build,test]
    env:
      VERSION: ${{ needs.build.outputs.version }}
    steps:
    - name: Show Version
      run: echo "$VERSION"
