# GitHub Actions

Testery integrates with GitHub Actions via the [Testery CLI](https://docs.testery.io/integrations/testery-cli-docs).

You'll need to define a GitHub Actions workflow. This is done by creating a yml file in the `.github/workflows` folder in your repository.

**Step 1. Retrieve your Testery API Token.** To retrieve your token, click **Settings → Integrations → Show API Token** and copy the token that is displayed. Keep this token secure as it allows access to Testery on your behalf.

**Step 2. Store your Testery API Token as a** [**GitHub Actions secret**](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets)**.** This is referenced in your GitHub Actions workflow as follows:

```yaml
jobs:
  build:
    ...
    env:
      TESTERY_TOKEN: ${{ secrets.TesteryTokenProd }}
    ...
```

**Step 3.** **Add steps to your GitHub Actions workflow to install the** [**Testery CLI**](https://docs.testery.io/integrations/testery-cli-docs) **and create the test run.**

Here is a sample `.github/workflows/testery.yml`

```yaml
name: Testery Tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    env:
      TESTERY_TOKEN: ${{ secrets.TesteryTokenProd }}

    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: "3.x"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install testery --upgrade
      - name: Deploy Application
        run: |
          ... logic to deploy your application ...
      - name: Run Testery Tests
        run: |
          # Create test run.
          testery create-test-run --api-url https://api.testery.io/api --token "$TESTERY_TOKEN" --include-tags "smoke" \
              --variable "TEST_URL=${TEST_URL}" \
              --git-ref "$GITHUB_SHA" --project "example-webdriverio" --environment "testery-dev" \
              --wait-for-results

```
