Skip to content

Commit de68df0

Browse files
docs: Fix outdated continuous integration docs (#1709)
Co-authored-by: Michał Olender <[email protected]>
1 parent 8a77639 commit de68df0

File tree

2 files changed

+81
-31
lines changed

2 files changed

+81
-31
lines changed
Lines changed: 81 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
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.
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.
45
slug: /actors/development/deployment/continuous-integration
56
sidebar_position: 2
67
---
78

89
# Continuous integration for Actors
910

10-
**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.**
1112

1213
import Tabs from '@theme/Tabs';
1314
import TabItem from '@theme/TabItem';
@@ -18,37 +19,87 @@ Automating your Actor development process can save time and reduce errors, espec
1819

1920
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).
2021

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

23-
## Set up automated builds and tests
23+
:::tip Using Bitbucket?
2424

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

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:
41+
42+
```cURL
43+
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60
44+
```
45+
46+
:::note API token
47+
48+
Make sure you select the correct API token from the dropdown.
49+
50+
:::
51+
52+
1. In your GitHub repository, go to Settings > Webhooks > Add webhook.
53+
1. Paste the API URL into the Payload URL field and add the webhook.
54+
55+
![GitHub integration](./images/ci-github-integration.png)
56+
57+
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.
2862
1. Get your Apify API token from the [Apify Console](https://console.apify.com/settings/integrations)
2963
3064
![Apify token in app](./images/ci-token.png)
3165
3266
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+
![Add Apify token to secrets](./images/ci-add-token.png)
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.
79+
80+
:::
3781
3882
```cURL
39-
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60
83+
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=latest&waitForFinish=60
4084
```
4185
86+
1. Name the secret & paste in your API endpoint
87+
4288
![Add build Actor URL to secrets](./images/ci-add-build-url.png)
4389
44-
1. Name the secret
4590
1. Create GitHub Actions workflow files:
4691
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).
4893
4994
<Tabs groupId="main">
5095
<TabItem value="latest.yml" label="latest.yml">
5196
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+
52103
```yaml
53104
name: Test and build latest version
54105
on:
@@ -57,7 +108,7 @@ To set up automated builds and tests for your Actors you need to:
57108
- master
58109
- main
59110
jobs:
60-
test:
111+
test-and-build:
61112
runs-on: ubuntu-latest
62113
steps:
63114
# Install dependencies and run tests
@@ -66,51 +117,50 @@ To set up automated builds and tests for your Actors you need to:
66117
# Build latest version
67118
- uses: distributhor/workflow-webhook@v1
68119
env:
69-
webhook_url: ${{ secrets.LATEST_BUILD_URL }}
120+
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
70121
webhook_secret: ${{ secrets.APIFY_TOKEN }}
71122
72123
```
73124
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.
75126
76127
</TabItem>
77-
78128
<TabItem value="beta.yml" label="beta.yml">
79129
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+
80136
```yaml
81137
name: Test and build beta version
82138
on:
83139
push:
84140
branches:
85141
- develop
86142
jobs:
87-
test:
143+
test-and-build:
88144
runs-on: ubuntu-latest
89145
steps:
90146
# Install dependencies and run tests
91147
- uses: actions/checkout@v2
92148
- run: npm install && npm run test
93-
# Build latest version
149+
# Build beta version
94150
- uses: distributhor/workflow-webhook@v1
95151
env:
96-
webhook_url: ${{ secrets.BETA_BUILD_URL }}
152+
webhook_url: ${{ secrets.BUILD_ACTOR_URL }}
97153
webhook_secret: ${{ secrets.APIFY_TOKEN }}
98154
99155
```
100156
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.
102158
103159
</TabItem>
104160
</Tabs>
105161
106-
## GitHub integration
162+
## Conclusion
107163
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.
109165
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.
113-
114-
![GitHub integration](./images/ci-github-integration.png)
115-
116-
Now your Actor will automatically rebuild on every push to the GitHub repository.
166+
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)