docs: clarify ERC20 post-op paymaster revert risk (#1178) #104
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Revalidate Content | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "content/**/*.md" | |
| - "content/**/*.mdx" | |
| jobs: | |
| revalidate-content: | |
| name: Revalidate Changed Pages | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| actions: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history to compare all commits in push | |
| - name: Get changed MDX files | |
| id: changed-files | |
| run: | | |
| # Get all MDX files changed in this push (handles multiple commits) | |
| set +e | |
| CHANGED_FILES=$(git diff --name-only \ | |
| "${{ github.event.before }}" "${{ github.event.after }}" \ | |
| -- 'content/**/*.md' 'content/**/*.mdx') | |
| EXIT_CODE=$? | |
| set -e | |
| # Check for git errors | |
| if [ $EXIT_CODE -ne 0 ]; then | |
| echo "::error::git diff failed with exit code $EXIT_CODE" | |
| exit 1 | |
| fi | |
| # Handle empty result (no files changed) | |
| if [ -z "$CHANGED_FILES" ]; then | |
| echo "No MDX files changed in /content/ directory" | |
| echo "filePaths=[]" >> $GITHUB_OUTPUT | |
| echo "frontmatterChanged=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| # Detect whether any changed file has frontmatter changes | |
| FRONTMATTER_CHANGED=false | |
| extract_frontmatter() { | |
| local ref="$1" | |
| local path="$2" | |
| if ! git cat-file -e "${ref}:${path}" 2>/dev/null; then | |
| return 0 | |
| fi | |
| git show "${ref}:${path}" | awk ' | |
| NR == 1 && $0 != "---" { exit } | |
| NR == 1 && $0 == "---" { in_frontmatter = 1; next } | |
| in_frontmatter && $0 == "---" { exit } | |
| in_frontmatter { print } | |
| ' | |
| } | |
| while IFS= read -r FILE; do | |
| [ -z "$FILE" ] && continue | |
| OLD_FRONTMATTER=$(extract_frontmatter "${{ github.event.before }}" "$FILE") | |
| NEW_FRONTMATTER=$(extract_frontmatter "${{ github.event.after }}" "$FILE") | |
| if [ "$OLD_FRONTMATTER" != "$NEW_FRONTMATTER" ]; then | |
| FRONTMATTER_CHANGED=true | |
| echo "Frontmatter changed in: $FILE" | |
| break | |
| fi | |
| done <<< "$CHANGED_FILES" | |
| # Strip 'content/' prefix and convert to JSON array | |
| FILE_PATHS_JSON=$(echo "$CHANGED_FILES" | sed 's|^content/||' | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "File paths JSON: $FILE_PATHS_JSON" | |
| echo "frontmatterChanged: $FRONTMATTER_CHANGED" | |
| echo "filePaths=$FILE_PATHS_JSON" >> $GITHUB_OUTPUT | |
| echo "frontmatterChanged=$FRONTMATTER_CHANGED" >> $GITHUB_OUTPUT | |
| - name: Call revalidation API | |
| if: steps.changed-files.outputs.filePaths != '[]' | |
| run: | | |
| ALL_PATHS='${{ steps.changed-files.outputs.filePaths }}' | |
| TOTAL=$(echo "$ALL_PATHS" | jq 'length') | |
| BATCH_SIZE=50 | |
| SUCCEEDED=0 | |
| FAILED=0 | |
| BATCH_NUM=0 | |
| echo "Revalidating $TOTAL files in batches of $BATCH_SIZE" | |
| for ((i = 0; i < TOTAL; i += BATCH_SIZE)); do | |
| BATCH_NUM=$((BATCH_NUM + 1)) | |
| BATCH=$(echo "$ALL_PATHS" | jq -c ".[$i:$((i + BATCH_SIZE))]") | |
| CHUNK_SIZE=$(echo "$BATCH" | jq 'length') | |
| echo "" | |
| echo "=== Batch $BATCH_NUM ($CHUNK_SIZE paths, $((i + CHUNK_SIZE))/$TOTAL) ===" | |
| echo "$BATCH" | jq -r '.[]' | |
| PAYLOAD=$(jq -n --argjson paths "$BATCH" '{filePaths: $paths}') | |
| HTTP_CODE=$(curl -X POST "${{ secrets.DOCS_SITE_URL }}/api/revalidate/markdown" \ | |
| -H "Authorization: Bearer ${{ secrets.DOCS_SITE_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD" \ | |
| --max-time 120 \ | |
| -o response.json \ | |
| -w "%{http_code}" \ | |
| -s) || true | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| SUCCESS=$(jq -r '.success' response.json) | |
| if [ "$SUCCESS" = "true" ]; then | |
| COUNT=$(jq -r '(.revalidated // []) | length' response.json) | |
| echo "✅ Batch $BATCH_NUM: $COUNT paths revalidated" | |
| SUCCEEDED=$((SUCCEEDED + COUNT)) | |
| else | |
| echo "::warning::Batch $BATCH_NUM: HTTP 200 but success=false" | |
| jq -r '(.errors // [])[]?' response.json | |
| jq -r '[(.revalidated // [])[]? | select(.error) | .error] | .[]?' response.json | |
| ITEM_COUNT=$(jq -r '(.revalidated // []) | length' response.json) | |
| if [ "$ITEM_COUNT" -gt 0 ]; then | |
| if [ "$ITEM_COUNT" -gt "$CHUNK_SIZE" ]; then | |
| ITEM_COUNT=$CHUNK_SIZE | |
| fi | |
| ERRORS=$(jq -r '[(.revalidated // [])[]? | select(.error)] | length' response.json) | |
| ITEM_SUCCEEDED=$((ITEM_COUNT - ERRORS)) | |
| UNREPORTED=$((CHUNK_SIZE - ITEM_COUNT)) | |
| SUCCEEDED=$((SUCCEEDED + ITEM_SUCCEEDED)) | |
| FAILED=$((FAILED + ERRORS + UNREPORTED)) | |
| else | |
| FAILED=$((FAILED + CHUNK_SIZE)) | |
| fi | |
| fi | |
| else | |
| echo "::error::Batch $BATCH_NUM: HTTP $HTTP_CODE" | |
| jq '.' response.json 2>/dev/null || cat response.json 2>/dev/null || true | |
| FAILED=$((FAILED + CHUNK_SIZE)) | |
| fi | |
| if [ $((i + BATCH_SIZE)) -lt "$TOTAL" ]; then | |
| sleep 2 | |
| fi | |
| done | |
| echo "" | |
| echo "=== Revalidation complete ===" | |
| echo "Total: $TOTAL | Succeeded: $SUCCEEDED | Failed: $FAILED" | |
| if [ "$FAILED" -gt 0 ]; then | |
| echo "::error::$FAILED paths failed to revalidate" | |
| exit 1 | |
| fi | |
| echo "::notice::✅ Successfully revalidated $SUCCEEDED files" | |
| - name: Trigger reindex if frontmatter changed | |
| if: steps.changed-files.outputs.frontmatterChanged == 'true' | |
| run: | | |
| echo "Frontmatter changes detected, triggering content indexer..." | |
| gh workflow run index-main-content.yml | |
| echo "::notice::✅ Triggered index-main-content.yml workflow" | |
| env: | |
| GH_TOKEN: ${{ github.token }} |