# GitHub Actions

> Upload JUnit test results from a GitHub Actions workflow to an Arcus test run so test case statuses update automatically.

Integrating GitHub with Arcus by Testsigma uploads your JUnit test results to a test run at the end of a workflow, so test case statuses update automatically.

## Prerequisites

- A GitHub account.
- A project in Arcus by Testsigma with at least one [test run](https://testsigma.com/docs/arcus/v2/run-tests/test-runs/).
- An Arcus by Testsigma [API token](https://testsigma.com/docs/arcus/v2/settings/api-keys/).

## Store the API token in GitHub

The workflow below reads the token from a repository secret named `TESTSIGMA_API_TOKEN`, so add it there rather than writing it into the workflow file.

## Configure the workflow

1. In your GitHub repository, open or create `.github/workflows/tests.yml`.

2. Add the following, then replace the 2 placeholders as described below.

```yaml
name: CI Build and Upload to Testsigma

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      TESTSIGMA_API_TOKEN: ${{ secrets.TESTSIGMA_API_TOKEN }}
    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Build and test with Maven
        run: mvn -B package --file pom.xml

      - name: Upload test results to Testsigma
        run: |
          curl --location 'https://arcus.testsigma.com/api/v1/projects/<Project_ID>/junit-import/test-run/<Run_ID>' \
          --header "Authorization: Bearer $TESTSIGMA_API_TOKEN" \
          --form "junit_xml=@target/surefire-reports/TEST-MyTests.xml"
```

- Replace `` with your project ID, which you can retrieve using the Arcus by Testsigma APIs.
- Replace `` with the run ID, which appears in the URL when you view a test run: `https://test-management.testsigma.com/ui/test_runs//`.
- Point `junit_xml` at the path your build writes its JUnit XML report to.
- Change `main` if your target branch is named something else.

## Trigger a build

Push a commit to the branch named in the workflow. GitHub Actions runs the workflow, and when it finishes the test run in Arcus by Testsigma updates with the execution results.
