Skip to content

Merge pull request #559 from future-agi/fix/rewrite-tracing-integrate #137

Merge pull request #559 from future-agi/fix/rewrite-tracing-integrate

Merge pull request #559 from future-agi/fix/rewrite-tracing-integrate #137

Workflow file for this run

name: Deploy Product Docs
on:
push:
branches: [astro]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# Fetch the chat-widget from the landing-page repo (pre-built dist is committed)
- name: Fetch @futureagi/chat-widget
run: |
git clone --depth 1 \
https://x-access-token:${{ secrets.GH_PAT }}@github.com/future-agi/landing-page.git .landing-tmp
cp -r .landing-tmp/docs-agent/packages/chat-widget ./chat-widget
rm -rf .landing-tmp
# Replace workspace:* with local file reference so npm can install it
- name: Patch chat-widget dependency
run: |
sed -i 's|"@futureagi/chat-widget": "workspace:\*"|"@futureagi/chat-widget": "file:./chat-widget"|' package.json
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json', 'package.json') }}
restore-keys: ${{ runner.os }}-npm-
- name: Install dependencies
run: npm install
- name: Create .env.production for build
run: |
printf '%s\n' \
"PUBLIC_DOCS_AGENT_URL=${{ secrets.PUBLIC_DOCS_AGENT_URL }}" \
"PUBLIC_TURNSTILE_SITE_KEY=${{ secrets.PUBLIC_TURNSTILE_SITE_KEY }}" \
"PUBLIC_POSTHOG_KEY=${{ secrets.PUBLIC_POSTHOG_KEY }}" \
"PUBLIC_POSTHOG_HOST=${{ secrets.PUBLIC_POSTHOG_HOST }}" \
> .env.production
- name: Build product docs
run: npx astro build && npx pagefind --site dist
env:
NODE_OPTIONS: --max-old-space-size=4096
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Sync dist/ to S3 with cache headers
run: |
# Hashed assets (_astro/) — immutable, cache for 1 year
# These never need invalidation; new deploys produce new filenames
aws s3 sync dist/_astro/ s3://${{ secrets.DOCS_S3_BUCKET }}/_astro/ \
--cache-control "public, max-age=31536000, immutable" --delete
# HTML & other files — CDN caches for 24hr, browser revalidates each visit
# stale-while-revalidate serves cached copy while fetching fresh in background
aws s3 sync dist/ s3://${{ secrets.DOCS_S3_BUCKET }}/ \
--cache-control "public, max-age=0, s-maxage=86400, stale-while-revalidate=3600, must-revalidate" \
--exclude "_astro/*" --delete
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id E21QMVEN8ZZTIM \
--paths "/*"
- name: Ping IndexNow (Bing + Yandex + ChatGPT)
run: |
# Collect all changed HTML pages from this deploy
URLS=$(find dist -name "index.html" -newer dist/_astro 2>/dev/null \
| sed 's|^dist||;s|/index.html$|/|' \
| head -100 \
| jq -R -s 'split("\n") | map(select(length > 0)) | map("https://docs.futureagi.com" + .)' )
# If no changed pages detected, submit the sitemap URL instead
if [ "$URLS" = "[]" ] || [ -z "$URLS" ]; then
URLS='["https://docs.futureagi.com/sitemap-index.xml"]'
fi
echo "Submitting $(echo $URLS | jq length) URLs to IndexNow"
curl -s -X POST "https://api.indexnow.org/indexnow" \
-H "Content-Type: application/json" \
-d "{
\"host\": \"docs.futureagi.com\",
\"key\": \"f91e235521964377b9904f2997d478ed\",
\"keyLocation\": \"https://docs.futureagi.com/f91e235521964377b9904f2997d478ed.txt\",
\"urlList\": $URLS
}" || echo "IndexNow ping failed (non-critical)"
- name: Ping search engines with sitemap
run: |
# Bing
curl -s "https://www.bing.com/ping?sitemap=https://docs.futureagi.com/sitemap-index.xml" || true
# Google
curl -s "https://www.google.com/ping?sitemap=https://docs.futureagi.com/sitemap-index.xml" || true
echo "Sitemap pinged"