Skip to content

Commit 7d61a05

Browse files
authored
Merge branch 'master' into feat/update-tagged-builds-api-docs
2 parents 2170eff + 3785c13 commit 7d61a05

File tree

76 files changed

+210
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+210
-183
lines changed

.github/styles/config/vocabularies/Docs/accept.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ subreddits?
119119
[Ss]ubwoofer
120120
Tripadvisor
121121
upvote
122-
walkthroughs?
122+
[Ww]alkthroughs?
123123

124124
ul
125125
[Aa]gno

.github/workflows/test.yaml

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -35,65 +35,65 @@ jobs:
3535
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}
3636
SEGMENT_TOKEN: ${{ secrets.SEGMENT_TOKEN }}
3737

38-
# - name: Install Nginx
39-
# run: |
40-
# sudo apt-get update
41-
# sudo apt-get install -y nginx
42-
#
43-
# - name: Start Docusaurus server
44-
# run: |
45-
# nohup npx docusaurus serve --port 3000 --no-open &
46-
# sleep 5
47-
# curl -f http://localhost:3000 > /dev/null
48-
#
49-
# - name: Start Nginx with project config
50-
# run: |
51-
# cat > default.conf <<EOF
52-
# worker_processes auto;
53-
# error_log $(pwd)/logs/error.log;
54-
# pid $(pwd)/logs/nginx.pid;
55-
# events {}
56-
# http {
57-
# access_log $(pwd)/logs/access.log;
58-
# include $(pwd)/nginx.conf;
59-
# }
60-
# EOF
61-
# sed -i 's|https://apify.github.io/apify-docs|http://localhost:3000|g' default.conf
62-
# mkdir -p $(pwd)/logs
63-
# nginx -c $(pwd)/default.conf
64-
# sleep 1
65-
#
66-
# - name: Run header assertions
67-
# run: |
68-
# set -euo pipefail
69-
# function assert_header() {
70-
# url=$1
71-
# header=$2
72-
# expected=$3
73-
# shift 3
74-
# extra_args=("$@")
75-
# actual=$(curl -s -D - -o /dev/null "${extra_args[@]}" "$url" | grep -i "^$header" | tr -d '\r' || true)
76-
# echo "→ $url → $actual"
77-
# echo "$actual" | grep -q "$expected" || (echo "❌ Expected '$expected' in '$header' for $url" && exit 1)
78-
# }
79-
#
80-
# echo "🧪 Checking Nginx responses..."
81-
#
82-
# assert_header "http://localhost:8080/" "Content-Type" "text/html"
83-
# assert_header "http://localhost:8080/" "Content-Type" "text/markdown" -H "Accept: text/markdown"
84-
# assert_header "http://localhost:8080/platform/proxy/usage" "Content-Type" "text/html"
85-
# assert_header "http://localhost:8080/platform/proxy/usage.md" "Content-Type" "text/markdown"
86-
# assert_header "http://localhost:8080/platform/proxy/usage" "Content-Type" "text/markdown" -H "Accept: text/markdown"
87-
# assert_header "http://localhost:8080/img/docs-og.png" "Content-Type" "image/png"
88-
# assert_header "http://localhost:8080/img/javascript-40x40.svg" "Content-Type" "image/svg"
89-
# assert_header "http://localhost:8080/llms.txt" "Content-Type" "text/markdown"
90-
# assert_header "http://localhost:8080/llms-full.txt" "Content-Type" "text/markdown"
91-
#
92-
# echo "✅ All Nginx header checks passed."
93-
#
94-
# - name: Stop Nginx
95-
# if: always()
96-
# run: nginx -c $(pwd)/default.conf -s stop
38+
- name: Install Nginx
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y nginx
42+
43+
- name: Start Docusaurus server
44+
run: |
45+
nohup npx docusaurus serve --port 3000 --no-open &
46+
sleep 5
47+
curl -f http://localhost:3000 > /dev/null
48+
49+
- name: Start Nginx with project config
50+
run: |
51+
cat > default.conf <<EOF
52+
worker_processes auto;
53+
error_log $(pwd)/logs/error.log;
54+
pid $(pwd)/logs/nginx.pid;
55+
events {}
56+
http {
57+
access_log $(pwd)/logs/access.log;
58+
include $(pwd)/nginx.conf;
59+
}
60+
EOF
61+
sed -i 's|https://apify.github.io/apify-docs|http://localhost:3000|g' default.conf
62+
mkdir -p $(pwd)/logs
63+
nginx -c $(pwd)/default.conf
64+
sleep 1
65+
66+
- name: Run header assertions
67+
run: |
68+
set -euo pipefail
69+
function assert_header() {
70+
url=$1
71+
header=$2
72+
expected=$3
73+
shift 3
74+
extra_args=("$@")
75+
actual=$(curl -s -D - -o /dev/null "${extra_args[@]}" "$url" | grep -i "^$header" | tr -d '\r' || true)
76+
echo "→ $url → $actual"
77+
echo "$actual" | grep -q "$expected" || (echo "❌ Expected '$expected' in '$header' for $url" && exit 1)
78+
}
79+
80+
echo "🧪 Checking Nginx responses..."
81+
82+
assert_header "http://localhost:8080/" "Content-Type" "text/html"
83+
assert_header "http://localhost:8080/" "Content-Type" "text/markdown" -H "Accept: text/markdown"
84+
assert_header "http://localhost:8080/platform/proxy/usage" "Content-Type" "text/html"
85+
assert_header "http://localhost:8080/platform/proxy/usage.md" "Content-Type" "text/markdown"
86+
assert_header "http://localhost:8080/platform/proxy/usage" "Content-Type" "text/markdown" -H "Accept: text/markdown"
87+
assert_header "http://localhost:8080/img/docs-og.png" "Content-Type" "image/png"
88+
assert_header "http://localhost:8080/img/javascript-40x40.svg" "Content-Type" "image/svg"
89+
assert_header "http://localhost:8080/llms.txt" "Content-Type" "text/markdown"
90+
assert_header "http://localhost:8080/llms-full.txt" "Content-Type" "text/markdown"
91+
92+
echo "✅ All Nginx header checks passed."
93+
94+
- name: Stop Nginx
95+
if: always()
96+
run: nginx -c $(pwd)/default.conf -s stop
9797

9898
lint_content:
9999
name: Lint markdown content

nginx.conf

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,47 @@
1+
map $http_accept $serve_markdown {
2+
default 0;
3+
~*text/plain 1;
4+
~*text/markdown 1;
5+
}
6+
7+
map $request_uri $has_no_extension {
8+
~^[^.]*$ 1;
9+
default 0;
10+
}
11+
112
server {
213
listen 0.0.0.0:8080;
3-
server_name docs.apify.com;
14+
server_name docs.apify.com docs.apify.loc;
15+
16+
proxy_set_header X-Real-IP $remote_addr;
17+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
18+
proxy_set_header X-Forwarded-Proto $scheme;
19+
20+
# comment out the resolver and use localhost:3000 for local development
21+
set $backend "https://apify.github.io/apify-docs";
22+
resolver 1.1.1.1 8.8.8.8 valid=30s ipv6=off;
23+
24+
location = / {
25+
if ($serve_markdown) {
26+
rewrite ^ /llms.txt last;
27+
}
28+
proxy_pass $backend/;
29+
}
30+
31+
location ~ ^/(llms|llms-full)\.txt$ {
32+
proxy_hide_header Content-Type;
33+
add_header Content-Type 'text/markdown; charset=utf-8' always;
34+
proxy_pass $backend$uri;
35+
}
436

537
location / {
6-
proxy_pass https://apify.github.io/apify-docs/;
38+
set $rewrite_condition "$serve_markdown$has_no_extension";
39+
set $proxy_path $request_uri;
40+
41+
if ($rewrite_condition = "11") {
42+
set $proxy_path "${request_uri}.md";
43+
}
44+
proxy_pass $backend$proxy_path;
745
}
846

947
# proxies to other repositories

0 commit comments

Comments
 (0)