# Release status statistics

name: IssueHelper

trigger:
  branches:
    exclude:
    - '*'

pr:
  branches:
    exclude:
    - '*'

schedules:
  - cron: "0 16 * * *"
    displayName: SDK Issue Statistics
    branches:
      include:
      - main
    always: true

variables:
  - group: Azure SDK Auto Release Pipeline Secrets
  - group: SDK Release Helper

jobs:
- job: IssueHelper
  displayName: IssueHelper Python 3.8
  timeoutInMinutes: 30
  strategy:
    maxParallel: 3
  pool:
    vmImage: 'ubuntu-20.04'
  steps:
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '3.8'
        addToPath: true
        architecture: 'x64'
    - bash: |
        script_path=$(pwd)/scripts/issue_helper
        cd ..
        git config --global user.email "IssueHelper"
        git config --global user.name "IssueHelper"

        # clone(REPO: https://github.com/Azure/azure-sdk-for-python.git, USR_NAME: Azure, USR_TOKEN: xxxxxxxxxxxxx)
        mkdir file-storage
        git clone ${FILE_REPO:0:8}$(USR_NAME):$(Yuchao-GitToken)@${FILE_REPO:8} $(pwd)/file-storage

        # import env variable
        export TOKEN=$(Yuchao-GitToken)
        export LANGUAGE=$(RUN_LANGUAGE)

        # create virtual env
        python -m venv venv-sdk
        source venv-sdk/bin/activate
        pip install -r $script_path/requirement.txt

        # checkout the target branch
        cd file-storage
        git checkout issue-helper

        # run
        python $script_path/main.py
