@@ -11,28 +11,33 @@ inputs:
1111 description : ' Directory where documentation files will be saved'
1212 required : false
1313 default : ' docs'
14-
1514 repository_url :
1615 description : ' Repository URL to fetch documentation for (defaults to current repository)'
1716 required : true
17+ source_branch :
18+ description : ' Source branch for comparison'
19+ required : true
20+ target_branch :
21+ description : ' Target branch for comparison'
22+ required : true
23+ output_format :
24+ description : ' Output format for documentation files (.md or .rst)'
25+ required : false
26+ default : ' .md'
1827
1928outputs :
2029 markdown_files_created :
2130 description : ' Number of Markdown files created'
2231 value : ${{ steps.process-docs.outputs.markdown_files_created }}
23-
2432 json_files_created :
2533 description : ' Number of JSON files created'
2634 value : ${{ steps.process-docs.outputs.json_files_created }}
27-
2835 output_directory :
2936 description : ' Directory where Markdown files were saved'
3037 value : ${{ steps.process-docs.outputs.output_directory }}
31-
3238 json_directory :
3339 description : ' Directory where JSON files were saved (.codeboarding)'
3440 value : ${{ steps.process-docs.outputs.json_directory }}
35-
3641 has_changes :
3742 description : ' Whether any files were created or changed'
3843 value : ${{ steps.process-docs.outputs.has_changes }}
@@ -59,14 +64,17 @@ runs:
5964 run : |
6065 ENDPOINT_URL="https://server.codeboarding.org/github_action"
6166 REPO_URL="${{ steps.repo-url.outputs.repo_url }}"
67+ SOURCE_BRANCH="${{ inputs.source_branch }}"
68+ TARGET_BRANCH="${{ inputs.target_branch }}"
69+ OUTPUT_FORMAT="${{ inputs.output_format }}"
6270
63- echo "Fetching documentation from: $ENDPOINT_URL?url=$REPO_URL"
71+ echo "Fetching documentation from: $ENDPOINT_URL?url=$REPO_URL&source_branch=$SOURCE_BRANCH&target_branch=$TARGET_BRANCH&output_format=$OUTPUT_FORMAT "
6472
6573 # Create temporary file for response
6674 TEMP_FILE=$(mktemp)
6775
6876 # Make the API call and save response
69- response=$(curl -s -w "%{http_code}" -o "$TEMP_FILE" "$ENDPOINT_URL?url=$REPO_URL")
77+ response=$(curl -s -w "%{http_code}" -o "$TEMP_FILE" "$ENDPOINT_URL?url=$REPO_URL&source_branch=$SOURCE_BRANCH&target_branch=$TARGET_BRANCH ")
7078 http_code=${response: -3}
7179
7280 if [ "$http_code" != "200" ]; then
@@ -94,6 +102,13 @@ runs:
94102 RESPONSE_FILE="${{ steps.fetch-docs.outputs.response_file }}"
95103 MD_OUTPUT_DIR="${{ inputs.output_directory }}"
96104 JSON_OUTPUT_DIR=".codeboarding"
105+ OUTPUT_FORMAT="${{ inputs.output_format }}"
106+
107+ # Validate output format
108+ if [[ "$OUTPUT_FORMAT" != ".md" && "$OUTPUT_FORMAT" != ".rst" ]]; then
109+ echo "Error: Invalid output format '$OUTPUT_FORMAT'. Must be either '.md' or '.rst'"
110+ exit 1
111+ fi
97112
98113 # Create the output directories
99114 mkdir -p "$MD_OUTPUT_DIR"
@@ -106,6 +121,7 @@ runs:
106121 echo "=== Processing Documentation Files ==="
107122 echo "Response JSON structure:"
108123 jq . "$RESPONSE_FILE"
124+ echo "Using output format: $OUTPUT_FORMAT"
109125
110126 # Parse JSON response and create files using keys as filenames
111127 if jq -e '.files' "$RESPONSE_FILE" > /dev/null; then
@@ -127,21 +143,28 @@ runs:
127143 echo "Created JSON file: $output_dir/$output_filename"
128144 JSON_FILES_CREATED=$((JSON_FILES_CREATED + 1))
129145 else
130- # Markdown file - add .md extension if not present
146+ # Documentation file - add appropriate extension if not present
131147 output_dir="$MD_OUTPUT_DIR"
132- if [[ "$filename" != *.md ]]; then
133- output_filename="${filename}.md"
148+
149+ # Check if filename has an extension
150+ if [[ "$filename" == *.* ]]; then
151+ # Extract basename without extension
152+ basename="${filename%.*}"
134153 else
135- output_filename ="$filename"
154+ basename ="$filename"
136155 fi
156+
157+ # Add the selected output format extension
158+ output_filename="${basename}${OUTPUT_FORMAT}"
159+
137160 echo "$content" > "$output_dir/$output_filename"
138- echo "Created Markdown file: $output_dir/$output_filename"
161+ echo "Created documentation file: $output_dir/$output_filename"
139162 MARKDOWN_FILES_CREATED=$((MARKDOWN_FILES_CREATED + 1))
140163 fi
141164 done
142165
143166 # Since we're in a subshell, we need to count files differently
144- MARKDOWN_FILES_CREATED=$(find "$MD_OUTPUT_DIR" -name "*.md " 2>/dev/null | wc -l || echo "0")
167+ MARKDOWN_FILES_CREATED=$(find "$MD_OUTPUT_DIR" -name "*${OUTPUT_FORMAT} " 2>/dev/null | wc -l || echo "0")
145168 JSON_FILES_CREATED=$(find "$JSON_OUTPUT_DIR" -name "*.json" 2>/dev/null | wc -l || echo "0")
146169 else
147170 echo "No 'files' key found in response JSON"
0 commit comments