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: Learn how to integrate your Actors by setting up automated builds, deploys, and testing for your Actors using GitHub Actions or Bitbucket Pipelines.
2
+
title: Continuous integration for Actors
3
+
sidebar_label: Continuous integration
4
+
description: Learn how to integrate your Actors by setting up automated builds, deploys, and testing for your Actors.
**Learn how to set up automated builds, deploys, and testing for your Actors using GitHub Actions or Bitbucket Pipelines.**
11
+
**Learn how to set up automated builds, deploys, and testing for your Actors.**
11
12
12
13
import Tabs from '@theme/Tabs';
13
14
import TabItem from '@theme/TabItem';
@@ -18,37 +19,87 @@ Automating your Actor development process can save time and reduce errors, espec
18
19
19
20
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).
20
21
21
-
This article focuses on GitHub, but [we also have a guide for Bitbucket](https://help.apify.com/en/articles/6988586-setting-up-continuous-integration-for-apify-actors-on-bitbucket).
22
22
23
-
## Set up automated builds and tests
23
+
:::tip Using Bitbucket?
24
24
25
-
To set up automated builds and tests for your Actors you need to:
25
+
Follow our 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).
26
26
27
-
1. Create a GitHub repository for your Actor code.
27
+
:::
28
+
29
+
30
+
Set up continuous integration for your Actors using one of these methods:
31
+
32
+
-[Trigger builds with a Webhook](#option-1-trigger-builds-with-a-webhook)
33
+
-[Set up automated builds and tests with GitHub Actions](#option-2-set-up-automated-builds-and-tests-with-github-actions)
34
+
35
+
Choose the method that best fits your workflow.
36
+
37
+
## Option 1: Trigger builds with a Webhook
38
+
39
+
1. Push your Actor to a GitHub repository.
40
+
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:
Now your Actor will automatically rebuild on every push to the GitHub repository.
58
+
59
+
## Option 2: Set up automated builds and tests with GitHub Actions
60
+
61
+
1. Push your Actor to a GitHub repository.
28
62
1. Get your Apify API token from the [Apify Console](https://console.apify.com/settings/integrations)
29
63
30
64

31
65
32
66
1. Add your Apify token to GitHub secrets
33
-
1. Go to your repository > Settings > Secrets > New repository secret
34
-
1. Name the secret & paste in your token
35
-
1. Add the Builds Actor API endpoint URL to GitHub secrets
36
-
1. Use this format:
67
+
1. Go to your repository > Settings > Secrets and variables > Actions > New repository secret
68
+
1. Name the secret and paste in your token
69
+
70
+

71
+
72
+
1. Add the Build Actor API endpoint URL to GitHub secrets
73
+
1. Go to your repository > Settings > Secrets and variables > Actions > New repository secret
74
+
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:
75
+
76
+
:::note API token
77
+
78
+
Make sure you select the correct API token from the dropdown.

43
89
44
-
1. Name the secret
45
90
1. Create GitHub Actions workflow files:
46
91
1. In your repository, create the `.github/workflows` directory
47
-
2. Add `latest.yml` and `beta.yml` files with the following content
92
+
1. Add `latest.yml`. If you want, you can also add `beta.yml` to build Actors from the develop branch (or other branches).
48
93
49
94
<Tabs groupId="main">
50
95
<TabItem value="latest.yml" label="latest.yml">
51
96
97
+
:::note Use your secret names
98
+
99
+
Make sure to use the exact secret names you set in the previous step.
100
+
101
+
:::
102
+
52
103
```yaml
53
104
name: Test and build latest version
54
105
on:
@@ -57,7 +108,7 @@ To set up automated builds and tests for your Actors you need to:
57
108
- master
58
109
- main
59
110
jobs:
60
-
test:
111
+
test-and-build:
61
112
runs-on: ubuntu-latest
62
113
steps:
63
114
# Install dependencies and run tests
@@ -66,51 +117,50 @@ To set up automated builds and tests for your Actors you need to:
66
117
# Build latest version
67
118
- uses: distributhor/workflow-webhook@v1
68
119
env:
69
-
webhook_url: ${{ secrets.LATEST_BUILD_URL }}
120
+
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
70
121
webhook_secret: ${{ secrets.APIFY_TOKEN }}
71
122
72
123
```
73
124
74
-
With this setup, pushing to the `main` or `master` branch builds a new latest version.
125
+
With this setup, pushing to the `main` or `master` branch tests the code and builds a new latest version.
75
126
76
127
</TabItem>
77
-
78
128
<TabItem value="beta.yml" label="beta.yml">
79
129
130
+
:::note Use your secret names
131
+
132
+
Make sure to use the exact secret names you set in the previous step.
133
+
134
+
:::
135
+
80
136
```yaml
81
137
name: Test and build beta version
82
138
on:
83
139
push:
84
140
branches:
85
141
- develop
86
142
jobs:
87
-
test:
143
+
test-and-build:
88
144
runs-on: ubuntu-latest
89
145
steps:
90
146
# Install dependencies and run tests
91
147
- uses: actions/checkout@v2
92
148
- run: npm install && npm run test
93
-
# Build latest version
149
+
# Build beta version
94
150
- uses: distributhor/workflow-webhook@v1
95
151
env:
96
-
webhook_url: ${{ secrets.BETA_BUILD_URL }}
152
+
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
97
153
webhook_secret: ${{ secrets.APIFY_TOKEN }}
98
154
99
155
```
100
156
101
-
With this setup, pushing to the `develop` branch builds a new beta version.
157
+
With this setup, pushing to the `develop` branch tests the code and builds a new beta version.
102
158
103
159
</TabItem>
104
160
</Tabs>
105
161
106
-
## GitHub integration
162
+
## Conclusion
107
163
108
-
To set up automatic builds from GitHub:
164
+
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.
109
165
110
-
1. Go to your Actor's detail page and coy the Build Actor API endpoint URL from the API tab.
111
-
1. In your GitHub repository, go to Settings > Webhooks > Add webhook.
0 commit comments