Skip to main content

Continuous integration for actors

Learn how to integrate your actors by setting up automated builds, deploys, and testing for your actors using GitHub Actions or Bitbucket Pipelines.

If you have a project consisting of several actors, or even one actor that requires frequent updates, you may want to automate some part of the development process. Instead of manually pushing your code, building each actor, then testing it, you could perform the whole process whenever you run git push.

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

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


Below is an example GitHub Actions workflow that will run your tests and build your actor every time you push your code to GitHub. This workflow supports both latest and beta builds. Copy the code into separate files in your actor repo's .github/workflows directory: e.g. .github/workflows/latest.yml and .github/workflows/beta.yml.

Each time you push to the main/master branch, a new latest version of your actor will be built. When you push to develop, a beta version will be built.

name: Test and build latest version
- master
- main
runs-on: ubuntu-latest
# Install dependencies and run tests
- uses: actions/checkout@v2
- run: npm install && npm run test
# Build latest version
- uses: distributhor/workflow-webhook@v1
webhook_url: ${{ secrets.LATEST_BUILD_URL }}
webhook_secret: ${{ secrets.APIFY_TOKEN }}

Find the Bitbucket version here.


To follow along, you will need a GitHub repository containing your Actor code and your Apify API token.

Find your Apify token in the Apify Console.

Apify token in app

Add the token to GitHub secrets. Go to your repo > Settings > Secrets > New repository secret.

Add the build actor API endpoint URL to GitHub secrets. Configure it to use your actor's ID and your API token.

Add build actor URL to secrets

Set up automatic builds

TODO: This duolicates somehow the above part

Once you have your prerequisites, you can start automating your builds. You can use webhooks or the Apify CLI (described in our Bitbucket guide) in your Git workflow.

To use webhooks, you can use the distributhor/workflow-webhook action, which uses the secrets described in the prerequisites section.

name: Build actor
- uses: distributhor/workflow-webhook@v1
webhook_url: ${{ secrets.[VERSION]_BUILD_URL }}
webhook_secret: ${{ secrets.APIFY_TOKEN }}

You can find your builds under the actor's Builds section.

An actor's builds

Automatic builds from GitHub

If the source code of an Actor is hosted in a Git repository, it is possible to set up an integration so that the Actor is automatically rebuilt on every push to the Git repository. For that, you only need to set up a webhook in your Git source control system that will invoke the Build actor API endpoint on every push.

For repositories on GitHub, you can use the following steps. First, go to the Actor detail page, open the API tab, and copy the Build actor API endpoint URL. It should look something like this:<API_TOKEN>&version=0.1

Then go to your GitHub repository, click Settings, select Webhooks tab and click Add webhook. Paste the API URL to the Payload URL as follows:

GitHub integration

And that's it! Now your Actor should automatically rebuild on every push to the GitHub repository.