Skip to content

Commit

Permalink
feat: enable multiple api specs (#21)
Browse files Browse the repository at this point in the history
- add script to move multiple OpenAPI specs files in one directory into individual directories
- change to directory path for listing of directories in index.html to enable directory listings also in those individual directories
#20
  • Loading branch information
evegufy authored Sep 25, 2024
1 parent 4f79811 commit fd2a4f7
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/publish_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ jobs:
echo "RANDOM=${RANDOM}" >> $GITHUB_OUTPUT
cd ${{ env.API_COLLECTOR_DIR }}
go run main.go -owner ${{ github.repository_owner }} -token ${{ secrets.GITHUB_TOKEN }}
- name: Move multiple OpenAPI specs files in one directory into individual directories
run: |
# Find all directories containing multiple *.yaml or *.yml files
find "${{ env.API_COLLECTOR_DIR }}/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: Check for specs
id: check_specs
run: |
Expand Down Expand Up @@ -108,7 +130,7 @@ jobs:
- name: Generate Directory Listings
uses: jayanta525/github-pages-directory-listing@v4.0.0
with:
FOLDER: ${{ steps.determine_directory.outputs.PRODUCT_PATH }}
FOLDER: ${{ steps.determine_directory.outputs.DIR_PATH }}
- uses: actions/upload-artifact@v4
with:
name: swagger-${{ steps.determine_directory.outputs.RANDOM }}
Expand Down

0 comments on commit fd2a4f7

Please sign in to comment.