> ## Documentation Index
> Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Github Action Basics

> Learn how to set up GitHub Actions for automated experiment testing

GitHub Actions allow you to automate workflows directly from your GitHub repository. It enables you to build, test, and deploy your code based on specific events (such as code pushes, pull requests, and more).

# Key Concepts of GitHub Actions

* **Workflows**: Automated processes that you define in your repository.
* **Jobs**: A workflow is composed of one or more jobs that can run sequentially or in parallel.
* **Steps**: Jobs contain steps that run commands in the job's virtual environment.
* **Actions**: The individual tasks that you can combine to create jobs and customize your workflow. You can use actions defined in the GitHub marketplace or create your own.

# Adding a GitHub Action to Your Repository

## Create a Workflow File:

* Workflow files are stored in the `.github/workflows` directory of your repository.
* Workflow files use YAML syntax and have a `.yml` extension.

### Example WorkFlow File:

```yaml theme={null}
name: AI Search - Correctness Check

on:
  push:
    paths:
      - copilot/search


jobs:
  run-script:
    runs-on: ubuntu-latest
    env:
      OPENAI_KEY: ${{ secrets.OPENAI_KEY }}  

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.10'

    - name: Install dependencies
      run: |
        pip install -q arize==7.36.0 arize-phoenix==4.29.0 nest_asyncio packaging openai 'gql[all]'
    - name: Run script
      run: python ./copilot/experiments/ai_search_test.py
```

#### Breakdown:

* `name`: The name of the workflow.
* `on`: The events that trigger the workflow. In this case, it's triggered on any push to the main branch.
* `jobs`: The jobs that will run as part of the workflow.
* `runs-on`: Specifies the virtual environment to run the job (e.g., `ubuntu-latest`).
* `steps`: The steps to run within the job.
  * `name`: A descriptive name for the step.
  * `uses`: Specifies an action to use (from the GitHub Actions marketplace).
  * `run`: Runs a command in the virtual environment.

## Common `on` Event Options:

1. **push:** Triggers the workflow when code is pushed to the repository.

   ```yaml theme={null}
   on:
     push:
       branches:
         - main
   ```
2. **pull\_request:** Triggers the workflow when a pull request is opened, updated, or closed.

   ```yaml theme={null}
   on:
     pull_request:
       branches:
         - main
   ```
3. **schedule:** Triggers the workflow on a scheduled time, using cron syntax.

   ```yaml theme={null}
   on:
     schedule:
       - cron: "0 0 * * *" # Runs every day at midnight
   ```
4. **workflow\_run:** Triggers the workflow when another workflow completes.

   ```yaml theme={null}
   on:
     workflow_run:
       workflows: ["Build"]
       types:
         - completed
   ```
5. **check\_suite:** Triggers the workflow when a check suite is completed.

   ```yaml theme={null}
   on:
     check_suite:
       types: [completed]
   ```
6. **check\_run:** Triggers the workflow when a check run is created or completed.

   ```yaml theme={null}
   on:
     check_run:
       types: [completed]
   ```
7. **Combining Multiple Events**\
   You can combine multiple events, filter by branch, tags, or specify types for more granular control over when a workflow runs.

   ```yaml theme={null}
   on:
     push:
       branches:
         - main
     pull_request:
       branches:
         - main
     schedule:
       - cron: "0 0 * * 0"  # Run on Sundays
   ```
8. **Filtering Events by Tags**

   ```yaml theme={null}
   on:
     push:
       tags:
         - "v1.*"
   ```
