You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Set up automated builds, deploys, and tests for your Actors using GitHub Actions, Bitbucket Pipelines, webhooks, or direct calls to the Apify API.
4
+
description: Set up automated builds, deploys, and tests for your Actors using GitHub Actions, webhooks, or the official GitHub integration.
@@ -13,152 +13,161 @@ import TabItem from '@theme/TabItem';
13
13
14
14
---
15
15
16
-
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.
17
-
18
-
You can automate Actor builds and tests using your Git repository's automated workflows like [GitHub Actions](https://github.com/features/actions) or [Bitbucket Pipelines](https://www.atlassian.com/software/bitbucket/features/pipelines).
19
-
20
-
21
-
:::tip Using Bitbucket?
22
-
23
-
Follow the step-by-step guide to set up continuous integration for your Actors with Bitbucket Pipelines: [Read the Bitbucket CI guide](https://help.apify.com/en/articles/6988586-setting-up-continuous-integration-for-apify-actors-on-bitbucket).
24
-
25
-
:::
26
-
16
+
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.
27
17
28
18
Set up continuous integration for your Actors using one of these methods:
29
19
30
-
-[Trigger builds with a Webhook](#option-1-trigger-builds-with-a-webhook)
31
-
-[Set up automated builds and tests with GitHub Actions](#option-2-set-up-automated-builds-and-tests-with-github-actions)
32
-
33
-
Choose the method that best fits your workflow.
34
-
35
-
## Option 1: Trigger builds with a webhook
36
-
37
-
1. Push your Actor to a GitHub repository.
38
-
1. Go to your Actor's detail page in Apify Console, click on the API tab in the top right, then select API Endpoints. Copy the **Build Actor** API endpoint URL. The format is as follows:
-[GitHub Actions](#github-actions) - the most flexible approach, with support for tests, multi-branch builds, and custom workflows.
21
+
-[API webhook](#api-webhook) - works with Bitbucket, GitLab, and other Git hosting providers that support webhooks.
22
+
-[GitHub integration](#github-integration) - the quickest setup with no workflow files needed, but less flexible than GitHub Actions.
23
+
24
+
## Set up automated builds with GitHub Actions {#github-actions}
25
+
26
+
To push your Actor source code to the Apify platform and build it on every push, use the official [`apify/push-actor-action`](https://github.com/apify/push-actor-action) GitHub Action. It works similarly to running `apify push` with the Apify CLI, and gives you full control over your CI pipeline: you can run tests, manage multiple branches, and customize the workflow.
27
+
28
+
### Prerequisites
29
+
30
+
- Your Actor source code in a GitHub repository with a valid `.actor/actor.json` file.
31
+
- An Apify API token. Find yours in [Apify Console](https://console.apify.com/settings/integrations) under **Settings** > **Integrations**.
32
+
33
+
### Step 1: Add your Apify token to GitHub secrets
34
+
35
+
1. Go to your GitHub repository.
36
+
1. Select **Settings** > **Security and quality** > **Secrets and variables** > **Actions**.
37
+
1. In the **Secrets** tab, go to **Repository secrets** and select **New repository secret**.
38
+
1. Complete the following fields:
39
+
40
+
-**Name**: use `APIFY_TOKEN` as a name for your secret.
41
+
-**Secret**: paste your Apify API token.
43
42
44
-
:::note API token
43
+
### Step 2: Create a GitHub Actions workflow
45
44
46
-
Make sure you select the correct API token from the dropdown.
45
+
In your repository, create a `.github/workflows` directory and add a workflow file. The following examples show common setups for production and beta branches.
47
46
48
-
:::
47
+
<TabsgroupId="main">
48
+
<TabItemvalue="latest.yml"label="latest.yml">
49
49
50
-
1. In your GitHub repository, go to Settings > Webhooks > Add webhook.
51
-
1. Paste the API URL into the Payload URL field and add the webhook.
50
+
Push to the Apify platform and build the Actor on every push to `main` or `master`:
Now your Actor will automatically rebuild on every push to the GitHub repository.
56
-
57
-
## Option 2: Set up automated builds and tests with GitHub Actions
58
-
59
-
1. Push your Actor to a GitHub repository.
60
-
1. Get your Apify API token from the [Apify Console](https://console.apify.com/settings/integrations)
61
-
62
-

63
-
64
-
1. Add your Apify token to GitHub secrets
65
-
1. Go to your repository > Settings > Secrets and variables > Actions > New repository secret
66
-
1. Name the secret and paste in your token
52
+
```yaml
53
+
name: Push and build latest version
54
+
on:
55
+
push:
56
+
branches:
57
+
- master
58
+
- main
59
+
jobs:
60
+
push-actor:
61
+
runs-on: ubuntu-latest
62
+
steps:
63
+
- uses: actions/checkout@v4
67
64
68
-

65
+
- name: Push Actor to Apify
66
+
uses: apify/push-actor-action@v1
67
+
with:
68
+
token: ${{ secrets.APIFY_TOKEN }}
69
+
```
69
70
70
-
1. Add the Build Actor API endpoint URL to GitHub secrets
71
-
1. Go to your repository > Settings > Secrets and variables > Actions > New repository secret
72
-
1. In Apify Console, go to your Actor's detail page, click the API tab in the top right, and then select API Endpoints. Copy the **Build Actor** API endpoint URL. The format is as follows:
71
+
</TabItem>
72
+
<TabItem value="beta.yml" label="beta.yml">
73
73
74
-
:::note API token
74
+
Push to the Apify platform and build a beta version on every push to `develop`:
75
75
76
-
Make sure you select the correct API token from the dropdown.
Run tests before pushing the Actor to the Apify platform:
85
99
86
-

100
+
```yaml
101
+
name: Test and push latest version
102
+
on:
103
+
push:
104
+
branches:
105
+
- master
106
+
- main
107
+
jobs:
108
+
test-and-push:
109
+
runs-on: ubuntu-latest
110
+
steps:
111
+
- uses: actions/checkout@v4
87
112
88
-
1. Create GitHub Actions workflow files:
89
-
1. In your repository, create the `.github/workflows` directory
90
-
1. Add `latest.yml`. If you want, you can also add `beta.yml` to build Actors from the develop branch (or other branches).
113
+
- name: Set up Node.js
114
+
uses: actions/setup-node@v4
115
+
with:
116
+
node-version: 22
91
117
92
-
<Tabs groupId="main">
93
-
<TabItem value="latest.yml" label="latest.yml">
118
+
- name: Install dependencies and run tests
119
+
run: npm install && npm run test
94
120
95
-
:::note Use your secret names
121
+
- name: Push Actor to Apify
122
+
id: push
123
+
uses: apify/push-actor-action@v1
124
+
with:
125
+
token: ${{ secrets.APIFY_TOKEN }}
96
126
97
-
Make sure to use the exact secret names you set in the previous step.
127
+
- name: Print build details
128
+
run: |
129
+
echo "Build ${{ steps.push.outputs.build-id }} finished with status ${{ steps.push.outputs.build-status }}"
130
+
```
131
+
132
+
</TabItem>
133
+
</Tabs>
134
+
135
+
For the full list of inputs (such as `actor-id`, `version`, and `working-directory`) and outputs, see the [`apify/push-actor-action` README](https://github.com/apify/push-actor-action).
136
+
137
+
## Trigger builds with a webhook {#api-webhook}
138
+
139
+
If you use Bitbucket, GitLab, or another Git hosting provider that supports webhooks, you can trigger Actor builds by calling the Apify build API on every push. This approach only triggers a build, it doesn't push your source code to the platform.
140
+
141
+
:::note Source code
142
+
143
+
When using the webhook approach, the Actor must have its source set to a Git repository in Apify Console. The webhook only triggers a build using the source already configured on the platform.
98
144
99
-
:::
100
-
101
-
```yaml
102
-
name: Test and build latest version
103
-
on:
104
-
push:
105
-
branches:
106
-
- master
107
-
- main
108
-
jobs:
109
-
test-and-build:
110
-
runs-on: ubuntu-latest
111
-
steps:
112
-
# Install dependencies and run tests
113
-
- uses: actions/checkout@v2
114
-
- run: npm install && npm run test
115
-
# Build latest version
116
-
- uses: distributhor/workflow-webhook@v1
117
-
env:
118
-
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
119
-
webhook_secret: ${{ secrets.APIFY_TOKEN }}
120
-
121
-
```
145
+
:::
122
146
123
-
With this setup, pushing to the `main` or `master` branch tests the code and builds a new latest version.
147
+
1. Go to your Actor's detail page in Apify Console.
148
+
1. Go to the **API** tab.
149
+
1. Select **API Endpoints** and copy the **Build Actor** API endpoint URL:
For a more complete Bitbucket setup with automated tests, see the [Bitbucket CI guide](https://help.apify.com/en/articles/6988586-setting-up-continuous-integration-for-apify-actors-on-bitbucket).
154
164
155
-
With this setup, pushing to the `develop` branch tests the code and builds a new beta version.
165
+
:::
156
166
157
-
</TabItem>
158
-
</Tabs>
167
+
## Use the Apify GitHub integration {#github-integration}
159
168
160
-
## Conclusion
169
+
Apify Console includes a built-in [GitHub integration](/platform/integrations/github) that links an Actor directly to a GitHub repository. When you connect a repository, Apify automatically rebuilds the Actor on every push - no workflow files or webhook configuration needed.
161
170
162
-
Setting up continuous integration (CI) for your Apify Actors ensures that CI automatically tests and builds your code whenever you push changes to your repository. This helps catch issues early and streamlines your deployment process, whether you're releasing to production or maintaining a beta branch.
171
+
This is the quickest way to get automated builds running, but it's less flexible than the GitHub Actions approach. It doesn't support running tests before building, managing multiple version tags from different branches, or customizing the build pipeline.
163
172
164
-
You can also integrate directly with GitHub, check out the [official Apify GitHub integration documentation](/platform/integrations/github).
173
+
To set it up, see the [GitHub integration](/platform/integrations/github) documentation.
0 commit comments