Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
16df023
feat: Add ops endpoints and refactor sync workflow
dohernandez Aug 21, 2025
8b39b2f
fix: Remove matrix variable from step ID in workflow
dohernandez Aug 21, 2025
6cfc3f8
fix: Correct parameter extraction in version-utils script
dohernandez Aug 21, 2025
3efbb20
fix: Redirect debug messages to stderr in version detection
dohernandez Aug 21, 2025
22f1b5b
fix: Add tag fetching to source repository clone
dohernandez Aug 21, 2025
7574631
fix: Use actions/checkout instead of manual git clone
dohernandez Aug 21, 2025
3cdb93d
fix: Add debugging and error handling to sync-files action
dohernandez Aug 21, 2025
8708255
debug: Add configuration debugging to sync workflow
dohernandez Aug 21, 2025
d52b46e
fix: Simplify sync approach using inline bash instead of composite ac…
dohernandez Aug 21, 2025
fb74cb5
fix: Add missing artifact tracking for result aggregation
dohernandez Aug 21, 2025
e14da74
chore: Shorten job name from 'Sync Documentation Files' to 'Sync Files'
dohernandez Aug 21, 2025
6e613fd
fix: Improve artifact aggregation with better error handling
dohernandez Aug 21, 2025
1f635b9
debug: Add comprehensive artifact debugging and error handling
dohernandez Aug 21, 2025
f6dbccb
fix: Correct YAML syntax error in multiline string
dohernandez Aug 21, 2025
b6d49a6
feat: use sync-files composite action to eliminate code duplication
dohernandez Aug 21, 2025
4ca25fd
fix: resolve YAML syntax error while keeping refactored state
dohernandez Aug 21, 2025
a7bf730
fix: resolve bash multiline string syntax error in aggregate job
dohernandez Aug 21, 2025
2f526f5
feat: Add api_ops_path input for syncing API ops files
dohernandez Aug 21, 2025
40dce20
feat: Fix aggregate metrics from report content in sync-docs-from-nod…
dohernandez Aug 21, 2025
289ef91
feat: Refactor sync logic into unified script and update workflow to …
dohernandez Aug 21, 2025
270a541
feat: Update PR workflow to print diff of changes before creating a p…
dohernandez Aug 21, 2025
3f84aa3
feat: Enhance local testing support by setting default output files i…
dohernandez Aug 21, 2025
326afe6
feat: Improve sync report titles based on sync type
dohernandez Aug 21, 2025
9fc679c
feat: Add repository checkout step in sync-docs workflow and update s…
dohernandez Aug 21, 2025
b5bba77
debug: Add extensive logging to sync-files.sh to identify exit code 1…
dohernandez Aug 21, 2025
e0e6d9b
debug: Add more detailed logging around file write operations
dohernandez Aug 21, 2025
271cfb8
debug: Add detailed directory test debugging
dohernandez Aug 21, 2025
799ed75
fix: Replace [[ ]] bash tests with [ ] POSIX tests for better compati…
dohernandez Aug 21, 2025
972387a
debug: Simplify bash options and parameter expansion
dohernandez Aug 21, 2025
706c734
debug: Add detailed if/else branch debugging
dohernandez Aug 21, 2025
32e215b
debug: Add bash version check and associative array debugging
dohernandez Aug 21, 2025
9a85bdc
fix: Replace process substitution with temporary file approach
dohernandez Aug 21, 2025
7666a4f
Add detailed debugging for counter initialization failure point
dohernandez Aug 22, 2025
ba36fa2
Add debugging for file processing loop failure point
dohernandez Aug 22, 2025
c034f5e
Add debugging for matches_pattern function call failure
dohernandez Aug 22, 2025
218b13a
Add debugging for variable assignment after filter match
dohernandez Aug 22, 2025
6ec010a
Add line-by-line debugging to identify exact failure point
dohernandez Aug 22, 2025
1aa8ccd
Add debugging after file processing loop completes
dohernandez Aug 22, 2025
674d271
Fix associative array expansion issue in deletion loop
dohernandez Aug 22, 2025
f5bf1ab
Fix arithmetic expansion to use POSIX-compatible syntax
dohernandez Aug 22, 2025
7b37b69
Prefix all debug messages with DEBUG: for easy identification
dohernandez Aug 22, 2025
8c484be
Fix config sync aggregation by adding missing summary lines
dohernandez Aug 22, 2025
788ec8e
Fix file persistence between jobs to enable proper change detection
dohernandez Aug 22, 2025
c139559
Fix BRANCH_NAME unbound variable error in git-utils.sh
dohernandez Aug 22, 2025
24b975d
Fix branch name capture by separating output streams
dohernandez Aug 22, 2025
a2e60a5
feat: Add sync report download and summary generation to workflow
dohernandez Aug 22, 2025
145d546
fix: improve workflow summary formatting
dohernandez Aug 22, 2025
d3f7ca5
fix: correct sync type titles in workflow summary
dohernandez Aug 22, 2025
754a2c4
refactor: Remove debug statements.
dohernandez Aug 22, 2025
82702fa
refactor: move excluded files to global configuration
dohernandez Aug 22, 2025
fc608f7
feat: add changelog path input to sync-docs-from-node workflow
dohernandez Aug 22, 2025
35e0124
feat: add API ops path to sync documentation workflow
dohernandez Aug 22, 2025
dda7b08
feat: update PR creation step in sync-docs-from-node workflow
dohernandez Aug 22, 2025
c5c05e0
feat: enhance PR creation process in sync-docs-from-node workflow
dohernandez Aug 22, 2025
6e7484d
feat: add API gen and debug filters to documentation sync workflow
dohernandez Aug 22, 2025
737c117
feat: remove example ops method documentation and clear meta.json
dohernandez Aug 22, 2025
4ff51ff
feat: capture and output PR URL in sync-docs-from-node workflow
dohernandez Aug 22, 2025
76760a3
feat: add step to download synced files in documentation sync workflow
dohernandez Aug 22, 2025
64cef07
feat: update PR handling in sync-docs-from-node workflow to support e…
dohernandez Aug 22, 2025
c9d1c5d
feat: add upload and download steps for processed files in sync-docs-…
dohernandez Aug 22, 2025
30a9045
feat: add debugging steps for file verification before and after docu…
dohernandez Aug 22, 2025
763862d
feat: remove continue-on-error option from download synced files step
dohernandez Aug 22, 2025
5bd62ae
feat: remove fallback download step for synced files in documentation…
dohernandez Aug 22, 2025
499511a
chore: clean up debug messages and temporary fixes from pipeline
dohernandez Aug 22, 2025
820c7f6
fix: repair syntax errors in sync-files.sh from cleanup
dohernandez Aug 22, 2025
26c6311
fix: repair remaining syntax errors from debug cleanup
dohernandez Aug 22, 2025
7bb7150
refactor: improve conditional logic in aggregate-reports.sh
dohernandez Aug 22, 2025
9418647
feat: add config sanitization step in sync-files.sh
dohernandez Aug 22, 2025
5577736
fix: remove redundant summary messages in sync-files.sh
dohernandez Aug 22, 2025
a78e13a
chore: remove unnecessary scripts
dohernandez Aug 22, 2025
5c36114
docs: update README to include config sanitization details and pipeli…
dohernandez Aug 22, 2025
e380a11
fix: include deletions in git add command in git-utils.sh
dohernandez Aug 22, 2025
e3bc319
feat: enhance artifact upload process for multiple sync types in sync…
dohernandez Aug 22, 2025
93a3c8f
feat: streamline artifact upload and download process in sync-docs-fr…
dohernandez Aug 22, 2025
92ba9f9
feat: enhance artifact upload and download process for multiple sync …
dohernandez Aug 22, 2025
4a4a5e0
feat: improve artifact download messages and streamline file handling…
dohernandez Aug 22, 2025
df88d59
feat: refine artifact upload names and enhance download messages in s…
dohernandez Aug 22, 2025
8e6d005
feat: add support for uploading changelog, config, API gen, debug, an…
dohernandez Aug 22, 2025
1557726
feat: enhance file merging and result storage in sync-docs-from-node.yml
dohernandez Aug 22, 2025
0406573
feat: implement deletion handling for synced files in sync-docs-from-…
dohernandez Aug 22, 2025
cdc46c7
feat: add cleanup step for intermediate artifacts in sync-docs-from-n…
dohernandez Aug 22, 2025
841d6fc
feat: update README to reflect changes in sync process and automatic …
dohernandez Aug 22, 2025
88670ce
feat: improve artifact deletion handling in sync-docs-from-node.yml
dohernandez Aug 22, 2025
b4f756c
feat: simplify intermediate artifact cleanup using delete-artifact ac…
dohernandez Aug 22, 2025
7681186
feat: update delete-artifact action to version 5 in sync-docs-from-no…
dohernandez Aug 22, 2025
bf57622
feat: add write permissions for actions in sync-docs-from-node.yml
dohernandez Aug 22, 2025
0dc42e2
feat: add synced-files-final to the list of sync reports in sync-docs…
dohernandez Aug 22, 2025
d89a665
feat: enhance sync functionality more modularity
dohernandez Aug 25, 2025
680559d
feat: improve config sanitization and enhance file deletion safety in…
dohernandez Aug 25, 2025
acd932a
feat: enable cleanup of artifacts in sync-docs-from-node.yml
dohernandez Aug 25, 2025
af43272
feat: remove backup
dohernandez Aug 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/actions/sync-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: 'Sync Files'
description: 'Generic file/directory synchronization with filtering and exclusions'
inputs:
type:
description: 'Type identifier for the sync operation (for artifact naming)'
required: true
title:
description: 'Human-readable title for reports'
required: true
source_path:
description: 'Source file or directory path'
required: true
target_path:
description: 'Target file or directory path'
required: true
filter_pattern:
description: 'Regex pattern to filter files (only for directories)'
required: false
default: '.*'
exclude_files:
description: 'Comma-separated list of filenames to exclude'
required: false
default: 'README,CHANGELOG,.gitignore,.gitkeep'
sanitize_script:
description: 'Optional script path to run after sync (for sanitization/post-processing)'
required: false
default: ''
outputs:
added:
description: 'Number of files added'
value: ${{ steps.sync.outputs.added }}
updated:
description: 'Number of files updated'
value: ${{ steps.sync.outputs.updated }}
deleted:
description: 'Number of files deleted'
value: ${{ steps.sync.outputs.deleted }}
total:
description: 'Total number of changes'
value: ${{ steps.sync.outputs.total }}
runs:
using: 'composite'
steps:
- name: Prepare config file
if: inputs.type == 'config'
shell: bash
run: |
# For config type, handle special case:
# 1. Copy config.yaml.example to temp location as config.yaml
# 2. Run sanitization on the renamed file
# 3. Use the sanitized file as source for sync

if [[ -f "${{ inputs.source_path }}" ]]; then
# Create temp directory
TEMP_DIR=$(mktemp -d)
echo "TEMP_CONFIG_DIR=$TEMP_DIR" >> $GITHUB_ENV

# Copy and rename config.yaml.example to config.yaml
cp "${{ inputs.source_path }}" "$TEMP_DIR/config.yaml"

# Run sanitization if script is provided
if [[ -n "${{ inputs.sanitize_script }}" ]] && [[ -f "${{ inputs.sanitize_script }}" ]]; then
echo "Sanitizing config file..."
bash "${{ inputs.sanitize_script }}" "$TEMP_DIR/config.yaml"
fi

# Update source path for sync
echo "CONFIG_SOURCE=$TEMP_DIR/config.yaml" >> $GITHUB_ENV
else
echo "Config source file not found: ${{ inputs.source_path }}"
exit 1
fi

- name: Sync files
id: sync
shell: bash
run: |
# Use prepared config source if it's a config type, otherwise use original source
if [[ "${{ inputs.type }}" == "config" ]] && [[ -n "$CONFIG_SOURCE" ]]; then
SOURCE_PATH="$CONFIG_SOURCE"
else
SOURCE_PATH="${{ inputs.source_path }}"
fi

${{ github.action_path }}/sync.sh \
"${{ inputs.type }}" \
"${{ inputs.title }}" \
"$SOURCE_PATH" \
"${{ inputs.target_path }}" \
"${{ inputs.filter_pattern }}" \
"${{ inputs.exclude_files }}"

- name: Cleanup config temp directory
if: inputs.type == 'config' && always()
shell: bash
run: |
if [[ -n "$TEMP_CONFIG_DIR" ]] && [[ -d "$TEMP_CONFIG_DIR" ]]; then
rm -rf "$TEMP_CONFIG_DIR"
fi

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: synced-${{ inputs.type }}
path: artifacts/
retention-days: 1
238 changes: 238 additions & 0 deletions .github/actions/sync-files/sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
#!/bin/bash
set -e

# File/directory synchronization script for documentation
# Syncs .md and .mdx files with pattern filtering

# Get parameters
TYPE="$1"
TITLE="$2"
SOURCE_PATH="$3"
TARGET_PATH="$4"
FILTER_PATTERN="${5:-.*}"
EXCLUDE_FILES="${6:-README,CHANGELOG,.gitignore,.gitkeep}"

# Initialize metrics and lists
added=0
updated=0
deleted=0
added_files=()
updated_files=()
deleted_files=()

# Convert exclusions to array
IFS=',' read -ra EXCLUSIONS <<< "$EXCLUDE_FILES"

# Check if file should be excluded
is_excluded() {
local filename="$1"
for excluded in "${EXCLUSIONS[@]}"; do
[[ "$filename" == "$excluded" ]] && return 0
done
return 1
}

# Check if filename matches pattern
matches_pattern() {
local filename="$1"
local pattern="$2"

# Try perl first (supports PCRE including negative lookahead)
if command -v perl >/dev/null 2>&1; then
echo "$filename" | perl -ne "exit 0 if /^($pattern)\$/; exit 1"
return $?
fi

# Fallback to grep -E (doesn't support negative lookahead)
echo "$filename" | grep -E "^($pattern)$" >/dev/null 2>&1
return $?
}

# Handle single file sync
if [[ -f "$SOURCE_PATH" ]]; then
echo "Syncing file: $SOURCE_PATH -> $TARGET_PATH"
mkdir -p "$(dirname "$TARGET_PATH")"

if [[ -f "$TARGET_PATH" ]]; then
if ! cmp -s "$SOURCE_PATH" "$TARGET_PATH"; then
cp "$SOURCE_PATH" "$TARGET_PATH"
updated=1
updated_files+=("$(basename "$TARGET_PATH")")
echo "Updated: $(basename "$TARGET_PATH")"
fi
else
cp "$SOURCE_PATH" "$TARGET_PATH"
added=1
added_files+=("$(basename "$TARGET_PATH")")
echo "Added: $(basename "$TARGET_PATH")"
fi

# Handle directory sync
elif [[ -d "$SOURCE_PATH" ]]; then
echo "Syncing directory: $SOURCE_PATH -> $TARGET_PATH"
echo "Filter pattern: $FILTER_PATTERN"
echo "Exclude files: $EXCLUDE_FILES"

# Check if source directory has any files
if [[ -z "$(ls -A "$SOURCE_PATH" 2>/dev/null)" ]]; then
echo "Warning: Source directory is empty: $SOURCE_PATH"
# Create empty target to ensure it exists
mkdir -p "$TARGET_PATH"
added=0
updated=0
deleted=0
else
mkdir -p "$TARGET_PATH"

# Create temp directory with normalized source files
TEMP_SOURCE=$(mktemp -d)
trap "rm -rf $TEMP_SOURCE" EXIT

Comment on lines +89 to +90
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Fix trap quoting to avoid SC2064 and accidental early expansion

Use single quotes so the variable expands at signal time and quote the arg inside.

-    trap "rm -rf $TEMP_SOURCE" EXIT
+    trap 'rm -rf "$TEMP_SOURCE"' EXIT
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
trap "rm -rf $TEMP_SOURCE" EXIT
trap 'rm -rf "$TEMP_SOURCE"' EXIT
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 89-89: Use single quotes, otherwise this expands now rather than when signalled.

(SC2064)

🤖 Prompt for AI Agents
.github/actions/sync-files/sync.sh around lines 89-90: the trap uses double
quotes which causes immediate expansion and triggers shellcheck SC2064; change
the trap to use single quotes so $TEMP_SOURCE is expanded when the EXIT signal
occurs and ensure the rm -rf argument is quoted inside the single-quoted command
(e.g., use single quotes around the entire command and quote the variable
inside) to prevent accidental early expansion and word-splitting.

echo "Preparing source files..."

# Count source files
source_count=0

# Process and filter source files into temp directory
shopt -s nullglob # Handle case when no .md or .mdx files exist
for file in "$SOURCE_PATH"/*.md "$SOURCE_PATH"/*.mdx; do
[[ ! -f "$file" ]] && continue

basename_file=$(basename "$file")
basename_no_ext="${basename_file%.*}"

# Skip excluded files
is_excluded "$basename_no_ext" && continue

# Skip if doesn't match pattern
matches_pattern "$basename_no_ext" "$FILTER_PATTERN" || continue

# Copy to temp with .mdx extension
cp "$file" "$TEMP_SOURCE/${basename_no_ext}.mdx"
source_count=$((source_count + 1))
echo " Processing: $basename_file"
done
shopt -u nullglob

echo "Processed $source_count source files"

# Track existing target files (using simple array for compatibility)
existing_files=()
if [[ -d "$TARGET_PATH" ]]; then
while IFS= read -r file; do
[[ -n "$file" ]] && existing_files+=("$file")
done < <(find "$TARGET_PATH" -type f -name "*.mdx" 2>/dev/null)
fi

# Sync from temp source to target
for source_file in "$TEMP_SOURCE"/*.mdx; do
[[ ! -f "$source_file" ]] && continue

basename_file=$(basename "$source_file")
target_file="$TARGET_PATH/$basename_file"

if [[ -f "$target_file" ]]; then
if ! cmp -s "$source_file" "$target_file"; then
cp "$source_file" "$target_file"
updated=$((updated + 1))
updated_files+=("$basename_file")
echo "Updated: $basename_file"
fi
# Remove from existing files array
new_existing=()
for ef in "${existing_files[@]}"; do
[[ "$(basename "$ef")" != "$basename_file" ]] && new_existing+=("$ef")
done
existing_files=("${new_existing[@]}")
else
cp "$source_file" "$target_file"
added=$((added + 1))
added_files+=("$basename_file")
echo "Added: $basename_file"
fi
done

# Delete orphaned files only if we had source files to sync
if [[ "$source_count" -gt 0 ]]; then
# Safe to delete orphaned files (preserve _meta.json)
for target_file in "${existing_files[@]}"; do
if [[ -f "$target_file" && "$(basename "$target_file")" != "_meta.json" ]]; then
rm "$target_file"
deleted=$((deleted + 1))
deleted_files+=("$(basename "$target_file")")
echo "Deleted: $(basename "$target_file")"
fi
done
else
echo "Warning: No source files matched filter; skipping deletion phase for safety"
echo " This prevents accidental mass deletion of target files"
fi
fi # End of non-empty directory check
else
echo "Source not found: $SOURCE_PATH"
exit 1
fi

# Output metrics
total=$((added + updated + deleted))
echo "added=$added" >> "$GITHUB_OUTPUT"
echo "updated=$updated" >> "$GITHUB_OUTPUT"
echo "deleted=$deleted" >> "$GITHUB_OUTPUT"
echo "total=$total" >> "$GITHUB_OUTPUT"

# Create artifact directory with report and synced files
mkdir -p artifacts

# Create summary report at root of artifacts
REPORT_FILE="artifacts/sync_report_${TYPE}.md"
cat > "$REPORT_FILE" <<EOF
## ${TITLE}

### Summary
- **Added**: $added files
- **Updated**: $updated files
- **Deleted**: $deleted files
- **Total changes**: $total

### Synced Files Location
Path: \`${TARGET_PATH}\`
EOF

# Add file lists to report
if [[ ${#added_files[@]} -gt 0 ]]; then
echo "" >> "$REPORT_FILE"
echo "### Added Files" >> "$REPORT_FILE"
for file in "${added_files[@]}"; do
echo "- $file" >> "$REPORT_FILE"
done
fi

if [[ ${#updated_files[@]} -gt 0 ]]; then
echo "" >> "$REPORT_FILE"
echo "### Updated Files" >> "$REPORT_FILE"
for file in "${updated_files[@]}"; do
echo "- $file" >> "$REPORT_FILE"
done
fi

if [[ ${#deleted_files[@]} -gt 0 ]]; then
echo "" >> "$REPORT_FILE"
echo "### Deleted Files" >> "$REPORT_FILE"
for file in "${deleted_files[@]}"; do
echo "- $file" >> "$REPORT_FILE"
done
fi

# Copy whatever is in target to artifacts
if [[ -f "$TARGET_PATH" ]]; then
# Single file
mkdir -p "artifacts/$(dirname "$TARGET_PATH")"
cp "$TARGET_PATH" "artifacts/${TARGET_PATH}"

elif [[ -d "$TARGET_PATH" ]]; then
# Directory - just copy everything
mkdir -p "artifacts/${TARGET_PATH}"
cp -r "$TARGET_PATH"/* "artifacts/${TARGET_PATH}/" 2>/dev/null || true
fi

echo "Sync completed: $total changes"
Loading