Skip to content

Commit 376364a

Browse files
committed
feat: send CI origin and GitHub Actions run URL on API requests
When CI=true, send X-Apify-Request-Origin: CI instead of CLI. In GitHub Actions, also send X-Apify-Github-Actions-Run-Url so Console can link build rows back to the workflow run. Partially resolves apify/apify-core#26861
1 parent 66abc66 commit 376364a

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"dependencies": {
6868
"@apify/actor-memory-expression": "^0.1.12",
6969
"@apify/actor-templates": "^0.1.5",
70-
"@apify/consts": "^2.36.0",
70+
"@apify/consts": "^2.53.0",
7171
"@apify/input_schema": "^3.17.0",
7272
"@apify/json_schemas": "^0.13.0",
7373
"@apify/utilities": "^2.18.0",

src/lib/consts.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { homedir } from 'node:os';
44
import { join } from 'node:path';
5+
import process from 'node:process';
56

67
import { META_ORIGINS } from '@apify/consts';
78

@@ -55,7 +56,14 @@ export const LOCAL_CONFIG_PATH = join(ACTOR_SPECIFICATION_FOLDER, LOCAL_CONFIG_N
5556

5657
export const SUPPORTED_NODEJS_VERSION = pkg.engines.node;
5758

58-
export const APIFY_CLIENT_DEFAULT_HEADERS = { 'X-Apify-Request-Origin': META_ORIGINS.CLI };
59+
const githubActionsRunUrl = process.env.GITHUB_ACTIONS === 'true'
60+
? `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
61+
: undefined;
62+
63+
export const APIFY_CLIENT_DEFAULT_HEADERS: Record<string, string> = {
64+
'X-Apify-Request-Origin': process.env.CI === 'true' ? META_ORIGINS.CI : META_ORIGINS.CLI,
65+
...(githubActionsRunUrl && { 'X-Apify-Github-Actions-Run-Url': githubActionsRunUrl }),
66+
};
5967

6068
export const MINIMUM_SUPPORTED_PYTHON_VERSION = '3.9.0';
6169

yarn.lock

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,20 @@ __metadata:
3434
languageName: node
3535
linkType: hard
3636

37-
"@apify/consts@npm:^2.20.0, @apify/consts@npm:^2.36.0, @apify/consts@npm:^2.50.0, @apify/consts@npm:^2.51.0, @apify/consts@npm:^2.51.1, @apify/consts@npm:^2.52.1":
37+
"@apify/consts@npm:^2.20.0, @apify/consts@npm:^2.50.0, @apify/consts@npm:^2.51.0, @apify/consts@npm:^2.51.1, @apify/consts@npm:^2.52.1":
3838
version: 2.52.1
3939
resolution: "@apify/consts@npm:2.52.1"
4040
checksum: 10c0/86d3a6b8a137bfecdb103a34b089c550a3a16d44b9b8b4373b1aec59ceacc91e444c7e121267b9d66363ce47efad650d5a50a1fd0800e0359eb1c67aec9d4b1e
4141
languageName: node
4242
linkType: hard
4343

44+
"@apify/consts@npm:^2.53.0":
45+
version: 2.53.0
46+
resolution: "@apify/consts@npm:2.53.0"
47+
checksum: 10c0/e2aa4a616d9ce60940fff8c1371cdbefb1aeb1a5408f6261c396efe6119da1c14a6ef3b5cb3f1d8a6247cf8d7c3e85bdf2a2e44302d33d2fa73f5c01d1773e30
48+
languageName: node
49+
linkType: hard
50+
4451
"@apify/datastructures@npm:^2.0.0":
4552
version: 2.0.3
4653
resolution: "@apify/datastructures@npm:2.0.3"
@@ -2202,7 +2209,7 @@ __metadata:
22022209
dependencies:
22032210
"@apify/actor-memory-expression": "npm:^0.1.12"
22042211
"@apify/actor-templates": "npm:^0.1.5"
2205-
"@apify/consts": "npm:^2.36.0"
2212+
"@apify/consts": "npm:^2.53.0"
22062213
"@apify/eslint-config": "npm:^1.0.0"
22072214
"@apify/input_schema": "npm:^3.17.0"
22082215
"@apify/json_schemas": "npm:^0.13.0"

0 commit comments

Comments
 (0)