Skip to content

Commit 73c9ce4

Browse files
docs: Fix outdated continuous integration docs
1 parent 2e0ec66 commit 73c9ce4

File tree

2 files changed

+61
-28
lines changed

2 files changed

+61
-28
lines changed
Lines changed: 61 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: Continuous integration
3-
description: Learn how to integrate your Actors by setting up automated builds, deploys, and testing for your Actors using GitHub Actions or Bitbucket Pipelines.
3+
description: Learn how to integrate your Actors by setting up automated builds, deploys, and testing for your Actors.
44
slug: /actors/development/deployment/continuous-integration
55
sidebar_position: 2
66
---
77

88
# Continuous integration for Actors
99

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

1212
import Tabs from '@theme/Tabs';
1313
import TabItem from '@theme/TabItem';
@@ -18,37 +18,73 @@ Automating your Actor development process can save time and reduce errors, espec
1818

1919
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).
2020

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).
2221

23-
## Set up automated builds and tests
22+
:::tip Using Bitbucket?
23+
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).
24+
:::
2425

25-
To set up automated builds and tests for your Actors you need to:
26+
There are two main ways to set up continuous integration for your Actors: [Trigger builds with a Webhook](#option-1-trigger-builds-with-a-webhook), or [Set up automated builds and tests with GitHub Actions](#option-2-set-up-automated-builds-and-tests-with-github-actions). Choose the method that best fits your workflow.
2627

27-
1. Create a GitHub repository for your Actor code.
28+
## Option 1: Trigger builds with a Webhook
29+
30+
To set up triggered builds with a webhook:
31+
32+
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:
33+
34+
```cURL
35+
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60
36+
```
37+
38+
:::note API token
39+
Make sure you select the correct API token from the dropdown.
40+
:::
41+
1. In your GitHub repository, go to Settings > Webhooks > Add webhook.
42+
1. Paste the API URL into the Payload URL field and add the webhook.
43+
44+
![GitHub integration](./images/ci-github-integration.png)
45+
46+
Now your Actor will automatically rebuild on every push to the GitHub repository.
47+
48+
## Option 2: Set up automated builds and tests with GitHub Actions
49+
50+
To set up automated builds and tests with GitHub Actions, you need to:
51+
52+
1. You need to push your Actor to a GitHub repository.
2853
1. Get your Apify API token from the [Apify Console](https://console.apify.com/settings/integrations)
2954
3055
![Apify token in app](./images/ci-token.png)
3156
3257
1. Add your Apify token to GitHub secrets
33-
1. Go to your repository > Settings > Secrets > New repository secret
58+
1. Go to your repository > Settings > Secrets and variables > Actions > New repository secret
3459
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:
60+
61+
![Add Apify token to secrets](./images/ci-add-token.png)
62+
63+
1. Add the Build Actor API endpoint URL to GitHub secrets
64+
1. Go to your repository > Settings > Secrets and variables > Actions > New repository secret
65+
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:
66+
:::note API token
67+
Make sure you select the correct API token from the dropdown.
68+
:::
3769
3870
```cURL
3971
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60
4072
```
41-
73+
1. Name the secret & paste in your API endpoint
74+
4275
![Add build Actor URL to secrets](./images/ci-add-build-url.png)
4376
44-
1. Name the secret
4577
1. Create GitHub Actions workflow files:
4678
1. In your repository, create the `.github/workflows` directory
47-
2. Add `latest.yml` and `beta.yml` files with the following content
79+
1. Add `latest.yml`. If you want, you can also add `beta.yml` to build actors from the develop branch (or other branches).
4880
4981
<Tabs groupId="main">
5082
<TabItem value="latest.yml" label="latest.yml">
5183
84+
:::note Use your secret names
85+
Make sure to use the exact secret names you set in the previous step.
86+
:::
87+
5288
```yaml
5389
name: Test and build latest version
5490
on:
@@ -57,7 +93,7 @@ To set up automated builds and tests for your Actors you need to:
5793
- master
5894
- main
5995
jobs:
60-
test:
96+
test-and-build:
6197
runs-on: ubuntu-latest
6298
steps:
6399
# Install dependencies and run tests
@@ -66,25 +102,28 @@ To set up automated builds and tests for your Actors you need to:
66102
# Build latest version
67103
- uses: distributhor/workflow-webhook@v1
68104
env:
69-
webhook_url: ${{ secrets.LATEST_BUILD_URL }}
105+
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
70106
webhook_secret: ${{ secrets.APIFY_TOKEN }}
71107
72108
```
73109
74-
With this setup, pushing to the `main` or `master` branch builds a new latest version.
110+
With this setup, pushing to the `main` or `master` branch tests the code and builds a new latest version.
75111
76112
</TabItem>
77-
78113
<TabItem value="beta.yml" label="beta.yml">
79114
115+
:::note Use your secret names
116+
Make sure to use the exact secret names you set in the previous step.
117+
:::
118+
80119
```yaml
81120
name: Test and build beta version
82121
on:
83122
push:
84123
branches:
85124
- develop
86125
jobs:
87-
test:
126+
test-and-build:
88127
runs-on: ubuntu-latest
89128
steps:
90129
# Install dependencies and run tests
@@ -93,24 +132,18 @@ To set up automated builds and tests for your Actors you need to:
93132
# Build latest version
94133
- uses: distributhor/workflow-webhook@v1
95134
env:
96-
webhook_url: ${{ secrets.BETA_BUILD_URL }}
135+
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
97136
webhook_secret: ${{ secrets.APIFY_TOKEN }}
98137
99138
```
100139
101-
With this setup, pushing to the `develop` branch builds a new beta version.
140+
With this setup, pushing to the `develop` branch tests the code and builds a new beta version.
102141
103142
</TabItem>
104143
</Tabs>
105144
106-
## GitHub integration
107-
108-
To set up automatic builds from GitHub:
109-
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.
112-
1. Paste the API URL into the Payload URL field.
145+
## Conclusion
113146
114-
![GitHub integration](./images/ci-github-integration.png)
147+
Setting up continuous integration (CI) for your Apify actors ensures that your code is always tested and built automatically 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.
115148
116-
Now your Actor will automatically rebuild on every push to the GitHub repository.
149+
You can also integrate directly with GitHub, check out the [official Apify GitHub integration documentation](/platform/integrations/github).
222 KB
Loading

0 commit comments

Comments
 (0)