Skip to content

Commit 8ccfb9b

Browse files
authored
docs: continuous integration rewrite (#1161)
improve structure & organization streamline prose remove redundant info & repetitions
1 parent f879ac6 commit 8ccfb9b

File tree

2 files changed

+75
-99
lines changed

2 files changed

+75
-99
lines changed

apify-docs-theme/src/theme/custom.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ html[data-theme='dark'] .runnable-code-block svg .apify-logo {
15521552
.prism-code.language-python .token-line::before,
15531553
.prism-code.language-dockerfile .token-line::before,
15541554
.prism-code.language-XML .token-line::before,
1555+
.prism-code.language-yaml .token-line::before,
15551556
.prism-code.language-js .token-line::before {
15561557
counter-increment: line-number;
15571558
content: counter(line-number);

sources/platform/actors/development/deployment/continuous_integration.md

Lines changed: 74 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -7,133 +7,108 @@ sidebar_position: 2
77

88
# Continuous integration for Actors
99

10-
**Learn how to integrate your Actors by setting 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 using GitHub Actions or Bitbucket Pipelines.**
1111

1212
import Tabs from '@theme/Tabs';
1313
import TabItem from '@theme/TabItem';
1414

1515
---
1616

17-
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`.
17+
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.
1818

19-
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://bitbucket.org/product/features/pipelines).
19+
This guide focuses on using GitHub Actions for continuous integration, but [we also have a guide for Bitbucket](https://help.apify.com/en/articles/1861038-setting-up-continuous-integration-for-apify-actors-on-bitbucket).
2020

21-
This article will focus on GitHub, but [we also have a guide for Bitbucket](https://help.apify.com/en/articles/1861038-setting-up-continuous-integration-for-apify-actors-on-bitbucket).
21+
## Set up automated builds and tests
2222

23-
## TL;DR
23+
To set up automated builds and tests for your Actors you need to:
2424

25-
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**.
25+
1. Create a GitHub repository for your Actor code.
26+
1. Get your Apify API token from the [Apify Console](https://console.apify.com/account#/integrations)
2627

27-
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.
28+
![Apify token in app](./images/ci-token.png)
2829

29-
<Tabs groupId="main">
30-
<TabItem value="latest.yml" label="latest.yml">
30+
1. Add your Apify token to GitHub secrets
31+
1. Go to your repo > Settings > Secrets > New repository secret
32+
1. Name the secret & paste in your token
33+
1. Add the Builds Actor API endpoint URL to GitHub secrets
34+
1. Use this format:
3135

32-
```yaml
33-
name: Test and build latest version
34-
on:
35-
push:
36-
branches:
37-
- master
38-
- main
39-
jobs:
40-
test:
41-
runs-on: ubuntu-latest
42-
steps:
43-
# Install dependencies and run tests
44-
- uses: actions/checkout@v2
45-
- run: npm install && npm run test
46-
# Build latest version
47-
- uses: distributhor/workflow-webhook@v1
48-
env:
49-
webhook_url: ${{ secrets.LATEST_BUILD_URL }}
50-
webhook_secret: ${{ secrets.APIFY_TOKEN }}
36+
```cURL
37+
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60
38+
```
5139
52-
```
40+
![Add build Actor URL to secrets](./images/ci-add-build-url.png)
5341
54-
</TabItem>
42+
1. Name the secret
43+
1. Create GitHub Actions workflow files:
44+
1. In your repo, create the `.github/workflows` directory
45+
2. Add `latest.yml` and `beta.yml` files with the following content
5546
47+
<Tabs groupId="main">
48+
<TabItem value="latest.yml" label="latest.yml">
5649
57-
<TabItem value="beta.yml" label="beta.yml">
50+
```yaml
51+
name: Test and build latest version
52+
on:
53+
push:
54+
branches:
55+
- master
56+
- main
57+
jobs:
58+
test:
59+
runs-on: ubuntu-latest
60+
steps:
61+
# Install dependencies and run tests
62+
- uses: actions/checkout@v2
63+
- run: npm install && npm run test
64+
# Build latest version
65+
- uses: distributhor/workflow-webhook@v1
66+
env:
67+
webhook_url: ${{ secrets.LATEST_BUILD_URL }}
68+
webhook_secret: ${{ secrets.APIFY_TOKEN }}
5869
59-
```yaml
60-
name: Test and build beta version
61-
on:
62-
push:
63-
branches:
64-
- develop
65-
jobs:
66-
test:
67-
runs-on: ubuntu-latest
68-
steps:
69-
# Install dependencies and run tests
70-
- uses: actions/checkout@v2
71-
- run: npm install && npm run test
72-
# Build latest version
73-
- uses: distributhor/workflow-webhook@v1
74-
env:
75-
webhook_url: ${{ secrets.BETA_BUILD_URL }}
76-
webhook_secret: ${{ secrets.APIFY_TOKEN }}
70+
```
7771
78-
```
72+
With this setup, pushing to the `main` or `master` branch builds a new latest version.
7973
80-
</TabItem>
81-
</Tabs>
74+
</TabItem>
8275
83-
[Find the Bitbucket version here](https://help.apify.com/en/articles/1861038-setting-up-continuous-integration-for-apify-actors-on-bitbucket).
76+
<TabItem value="beta.yml" label="beta.yml">
8477
85-
## Prerequisites
78+
```yaml
79+
name: Test and build beta version
80+
on:
81+
push:
82+
branches:
83+
- develop
84+
jobs:
85+
test:
86+
runs-on: ubuntu-latest
87+
steps:
88+
# Install dependencies and run tests
89+
- uses: actions/checkout@v2
90+
- run: npm install && npm run test
91+
# Build latest version
92+
- uses: distributhor/workflow-webhook@v1
93+
env:
94+
webhook_url: ${{ secrets.BETA_BUILD_URL }}
95+
webhook_secret: ${{ secrets.APIFY_TOKEN }}
8696
87-
To follow along, you will need a GitHub repository containing your [Actor](../index.md) code and your Apify API token.
97+
```
8898
89-
[Find your Apify token in the Apify Console](https://console.apify.com/account#/integrations).
99+
With this setup, pushing to the `develop` branch builds a new beta version.
90100
91-
![Apify token in app](./images/ci-token.png)
101+
</TabItem>
102+
</Tabs>
92103
93-
[Add the token to GitHub secrets](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository). Go to **your repo > Settings > Secrets > New repository secret**.
104+
## GitHub integration
94105
95-
Add the [**Build Actor** API endpoint URL](/api/v2#/reference/actors/build-collection/build-actor) to GitHub secrets. Configure it to use your Actor's ID and your API token.
106+
To set up automatic builds from GitHub:
96107
97-
```cURL
98-
https://api.apify.com/v2/acts/YOUR-ACTOR-NAME/builds?token=YOUR-TOKEN-HERE&version=0.0&tag=beta&waitForFinish=60
99-
```
100-
101-
![Add build Actor URL to secrets](./images/ci-add-build-url.png)
102-
103-
## Set up automatic builds
104-
105-
[//]: # (TODO: This duplicates somehow the above part)
106-
107-
Once you have your [prerequisites](#prerequisites), you can start automating your builds. You can use [webhooks](https://en.wikipedia.org/wiki/Webhook) or the [Apify CLI](/cli/) ([described in our Bitbucket guide](https://help.apify.com/en/articles/1861038-setting-up-continuous-integration-for-apify-actors-on-bitbucket)) in your Git workflow.
108-
109-
To use webhooks, you can use the [distributhor/workflow-webhook](https://github.com/distributhor/workflow-webhook) action, which uses the secrets described in the [prerequisites](#prerequisites) section.
110-
111-
```yaml
112-
name: Build Actor
113-
- uses: distributhor/workflow-webhook@v1
114-
env:
115-
webhook_url: ${{ secrets.[VERSION]_BUILD_URL }}
116-
webhook_secret: ${{ secrets.APIFY_TOKEN }}
117-
```
118-
119-
You can find your builds under the Actor's **Builds** section.
120-
121-
![An Actor's builds](./images/ci-builds.png)
122-
123-
## [](#github-integration) Automatic builds from GitHub
124-
125-
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/2I3DM8Nvu1M" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
126-
127-
If the source code of an Actor is hosted in a [Git repository](#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/v2/#/reference/actors/build-collection/build-actor) API endpoint on every push.
128-
129-
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:
130-
131-
```text
132-
https://api.apify.com/v2/acts/apify~hello-world/builds?token=<API_TOKEN>&version=0.1
133-
```
134-
135-
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:
108+
1. Go to your Actor's detail page and coy the Build Actor API endpoint URL from the API tab.
109+
1. In your GitHub repository, go to Settings > Webhooks > Add webhook.
110+
1. Paste the API URL into the Payload URL field.
136111
137112
![GitHub integration](./images/ci-github-integration.png)
138113
139-
And that's it! Now your Actor should automatically rebuild on every push to the GitHub repository.
114+
Now your Actor will automatically rebuild on every push to the GitHub repository.

0 commit comments

Comments
 (0)