diff --git a/.github/workflows/publish_api.yaml b/.github/workflows/publish_api.yaml index 46a94988..c1452aa9 100644 --- a/.github/workflows/publish_api.yaml +++ b/.github/workflows/publish_api.yaml @@ -72,6 +72,28 @@ jobs: path: docs pattern: openapi-* merge-multiple: true + - name: Move multiple OpenAPI specs files in one directory into individual directories + run: | + # Find all directories containing multiple *.yaml or *.yml files + find "$docs" -type d | while read -r DIR; do + # Count how many YAML/YML files are in the current directory + FILES=($(find "$DIR" -maxdepth 1 -type f \( -name "*.yaml" -o -name "*.yml" \))) + # If there are more than one YAML file in the directory + if [ ${#FILES[@]} -gt 1 ]; then + # Loop through each YAML file + for FILE in "${FILES[@]}"; do + # Extract the filename without the extension + FILENAME=$(basename "$FILE") + BASENAME="${FILENAME%.*}" + # Create a directory named after the file (without the extension) + TARGET_DIR="$DIR/$BASENAME" + mkdir -p "$TARGET_DIR" + # Move the file into the newly created directory + mv "$FILE" "$TARGET_DIR/" + done + fi + done + echo "Multiple OpenAPI specs files in one directory have been organized into individual directories." - name: Create OpenAPI specs list id: create_specs_list run: |