Skip to content

Commit 84eb53d

Browse files
authored
docs: Restructure topic on env vars (#1307)
The topic structure stopped making sense once we added the new env var. Closes #1279.
1 parent 84647b9 commit 84eb53d

2 files changed

Lines changed: 58 additions & 40 deletions

File tree

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ pnpm run dev:apify create my-actor
3333

3434
`pnpm run dev:actor` does the same for the in-Actor `actor` binary.
3535

36+
## Environment variables
37+
38+
Use the following environment variables to configure the CLI.
39+
40+
### `APIFY_CONSOLE_URL`
41+
42+
Changes the base URL of Apify Console that the CLI prints and opens. For example, the run, build, dataset and key-value store URLs, or the browser page for the `apify login` flow.
43+
44+
The default value is `https://console.apify.com`.
45+
46+
To point the CLI at a local Console instance during development, use:
47+
48+
```bash
49+
export APIFY_CONSOLE_URL=http://localhost:3000
50+
```
51+
52+
Note that if `APIFY_CONSOLE_URL` points at `localhost`, `apify login` validates your token against `http://localhost:3333`. All other commands still call the production API at `https://api.apify.com`.
53+
3654
## Code style
3755

3856
The repo uses three tools, wired together via a pre-commit hook (`husky` + `lint-staged`):

docs/vars.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
---
2-
description: Learn how use environment variables for Apify CLI
2+
description: Learn how to define environment variables for your Actors using the Apify CLI.
33
title: Environment variables
44
---
55

6-
There are two options how you can set up environment variables for Actors.
6+
You can use the CLI to set environment variables for your Actors.
77

8-
### Set up environment variables in `.actor/actor.json`
8+
For the list of the system variables that Apify provides, see [Environment variables](https://docs.apify.com/actors/development/programming-interface/environment-variables).
99

10-
All keys from `environmentVariables` will be set as environment variables into Apify platform after you push Actor to Apify. Current values on Apify will be overridden.
10+
## Custom environment variables
11+
12+
To pass additional configuration to your Actor, define custom environment variables.
13+
14+
### Define in `.actor/actor.json`
15+
16+
To set custom variables, add them to the `environmentVariables` object in `.actor/actor.json` and push the Actor to Apify:
1117

1218
```json
1319
{
@@ -22,10 +28,19 @@ All keys from `environmentVariables` will be set as environment variables into A
2228
}
2329
```
2430

25-
### Set up environment variables in Apify Console
31+
Variables defined in `.actor/actor.json` override the ones defined in Apify Console.
32+
33+
### Define in Apify Console
34+
35+
To set custom variables in Apify Console:
2636

27-
In [Apify Console](https://console.apify.com/actors) select your Actor, you can set up variables into Source tab.
28-
After setting up variables in the app, remove the `environmentVariables` from `.actor/actor.json`. Otherwise, variables from `.actor/actor.json` will override variables in the app.
37+
1. Log in to [Apify Console](https://console.apify.com).
38+
1. In the left-side panel, go to **Development** > **My Actors**.
39+
1. From the table, select the Actor you want to configure.
40+
1. Go to the **Source** tab > **Code**.
41+
1. Expand the **Environment variables** section.
42+
43+
Once done, delete `environmentVariables` from `.actor/actor.json`. Variables defined in that file override the ones defined in Apify Console.
2944

3045
```json
3146
{
@@ -36,41 +51,26 @@ After setting up variables in the app, remove the `environmentVariables` from `.
3651
}
3752
```
3853

39-
#### How to set secret environment variables in `.actor/actor.json`
54+
### Define secrets
4055

41-
CLI provides commands to manage secrets environment variables. Secrets are stored to the `~/.apify` directory.
42-
You can add a new secret using the command:
56+
You can use the CLI to manage secrets environment variables:
4357

44-
```bash
45-
apify secrets add mySecretPassword pwd1234
46-
```
58+
1. To add a secret, use the `apify secrets add` command. All secrets are stored in the `~/.apify` directory.
4759

48-
After adding a new secret you can use the secret in `.actor/actor.json`.
60+
```bash
61+
apify secrets add mySecretPassword pwd1234
62+
```
4963

50-
```text
51-
{
52-
"actorSpecification": 1,
53-
"name": "dataset-to-mysql",
54-
...
55-
"environmentVariables": {
56-
"MYSQL_PASSWORD": "@mySecretPassword"
57-
},
58-
...
59-
}
60-
```
61-
62-
## Environment variables that configure the CLI
63-
64-
Use the following environment variable to point the CLI at a non-production Apify Console, such as a staging deployment or a local instance during development.
65-
66-
### `APIFY_CONSOLE_URL`
67-
68-
Overrides the base URL of [Apify Console](https://console.apify.com) used when the CLI prints links. For example, run, build, dataset and key-value store URLs, or the `apify login` browser flow. When unset, the production Console at `https://console.apify.com` is used.
69-
70-
Set it to point at a local Console instance during development:
71-
72-
```bash
73-
export APIFY_CONSOLE_URL=http://localhost:3000
74-
```
64+
1. To reference the secret in `.actor/actor.json`, use the `@` prefix:
7565

76-
With a localhost Console, `apify login` also validates your token against the local API at `http://localhost:3333`.
66+
```text
67+
{
68+
"actorSpecification": 1,
69+
"name": "dataset-to-mysql",
70+
...
71+
"environmentVariables": {
72+
"MYSQL_PASSWORD": "@mySecretPassword"
73+
},
74+
...
75+
}
76+
```

0 commit comments

Comments
 (0)