Skip to main content

Continuous integration for Actors

Learn how to set up automated builds, deploys, and testing for your Actors using GitHub Actions or Bitbucket Pipelines.


Automating your Actor development process can save time and reduce errors, especially for projects with multiple Actors or frequent updates. Instead of manually pushing code, building Actors, and running tests, you can automate these steps to run whenever you push code to your repository.

You can automate Actor builds and tests using your Git repository's automated workflows like GitHub Actions or Bitbucket Pipelines.

This article focuses on GitHub, but we also have a guide for Bitbucket.

Set up automated builds and tests

To set up automated builds and tests for your Actors you need to:

  1. Create a GitHub repository for your Actor code.

  2. Get your Apify API token from the Apify Console

    Apify token in app

  3. Add your Apify token to GitHub secrets

    1. Go to your repo > Settings > Secrets > New repository secret
    2. Name the secret & paste in your token
  4. Add the Builds Actor API endpoint URL to GitHub secrets

    1. Use this format:

      https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60

      Add build Actor URL to secrets

    2. Name the secret

  5. Create GitHub Actions workflow files:

    1. In your repo, create the .github/workflows directory
    2. Add latest.yml and beta.yml files with the following content
    name: Test and build latest version
    on:
    push:
    branches:
    - master
    - main
    jobs:
    test:
    runs-on: ubuntu-latest
    steps:
    # Install dependencies and run tests
    - uses: actions/checkout@v2
    - run: npm install && npm run test
    # Build latest version
    - uses: distributhor/workflow-webhook@v1
    env:
    webhook_url: ${{ secrets.LATEST_BUILD_URL }}
    webhook_secret: ${{ secrets.APIFY_TOKEN }}

    With this setup, pushing to the main or master branch builds a new latest version.

GitHub integration

To set up automatic builds from GitHub:

  1. Go to your Actor's detail page and coy the Build Actor API endpoint URL from the API tab.
  2. In your GitHub repository, go to Settings > Webhooks > Add webhook.
  3. Paste the API URL into the Payload URL field.

GitHub integration

Now your Actor will automatically rebuild on every push to the GitHub repository.