Skip to main content

Working With Github Actions

Configuring the Applitools CI/CD Integration

  1. In the workflow YAML file, add the following:

    env:
    APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
    APPLITOOLS_BATCH_ID: ${{ github.event.pull_request.head.sha || github.sha }}
    • The example above assumes that you have access to the GitHub secrets service and have stored your Applitools API key in the GitHub secret name APPLITOOLS_API_KEY.

      To obtain your API key, see How to obtain your API key.

    • If you use the public cloud, the value of APPLITOOLS_SERVER_URL is https://eyesapi.applitools.com.

      If you run the Eyes server on a private cloud or on-premise system, then change the value assigned to the environment variable APPLITOOLS_SERVER_URL to the URL of your Eyes server.

  2. If your GitHub workflow includes two or more concurrent Eyes jobs, add another dependent job that waits for these jobs to complete and notifies Eyes that the batch has completed. For example, if you have three jobs called runtests1, runtests2, runtests3, add the following job to the YAML file:

    batch-completion-notification:
    # This runs after all the test jobs have completed
    needs: [runtests1, runtests2, runtests3]
    runs-on: ubuntu-latest
    steps:
    - name: Update Applitools batch status
    uses: wei/curl@v1.1.1
    with:
    args: -X POST -d -H "accept:*/*" https://eyesapi.applitools.com/api/externals/github/servers/github.com/commit/${{env.APPLITOOLS_BATCH_ID}}/complete?apiKey=${{env.APPLITOOLS_API_KEY}}

    If you use the optional APPLITOOLS_BATCH_BUILD_ID environment variable:

    batch-completion-notification:
    # This runs after all the test jobs have completed
    needs: [runtests1, runtests2, runtests3]
    runs-on: ubuntu-latest
    steps:
    - name: Update Applitools batch status
    uses: wei/curl@v1.1.1
    with:
    args: -X POST -d -H "accept:*/*" https://eyesapi.applitools.com/api/externals/github/servers/github.com/commit/${{env.APPLITOOLS_BATCH_ID}}/${{env.APPLITOOLS_BATCH_BUILD_ID}}/complete?apiKey=${{env.APPLITOOLS_API_KEY}}

Preparing For Commit Push Action

If you're triggering a build from commit push actions, the Eyes server must be notified. Here's an example of how to notify the Eyes Server using a curl request:

curl -L -d '' -X POST "$APPLITOOLS_SERVER_URL/api/externals/github/push?
apiKey=$APPLITOOLS_API_KEY&CommitSha=$APPLITOOLS_BATCH_ID&BranchName=${GITHUB_REPOSITORY}/${GITHUB_REF_NAME}
&ParentBranchName=<Parent branch name - optional>"