Skip to content

Commit af94f4c

Browse files
committed
docs: adapt workflow to upload json schema
1 parent c410643 commit af94f4c

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

.github/workflows/swagger_ui.yml

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
done
4646
4747
echo "Matrix JSON: $matrix"
48-
# Set the matrix output (using the new recommended GITHUB_OUTPUT mechanism)
48+
# Set the matrix output (using the GITHUB_OUTPUT mechanism)
4949
echo "matrix=$matrix" >> $GITHUB_OUTPUT
5050
5151
update-docs:
@@ -72,41 +72,26 @@ jobs:
7272
output: ${{ matrix.output }}
7373
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7474

75+
- name: Copy schemas folder if available
76+
run: |
77+
# For a spec like "./module/api_docs/my-api.yaml", the related schemas folder is assumed to be at "./module/schemas"
78+
parent_dir=$(dirname "$(dirname "${{ matrix.spec }}")")
79+
schemas_dir="$parent_dir/schemas"
80+
if [ -d "$schemas_dir" ]; then
81+
echo "Found schemas directory: $schemas_dir"
82+
# Copy the entire schemas folder into the output folder (as a subfolder named "schemas")
83+
mkdir -p "${{ matrix.output }}/schemas"
84+
cp -r "$schemas_dir/"* "${{ matrix.output }}/schemas/"
85+
echo "Copied schemas from $schemas_dir to ${{ matrix.output }}/schemas/"
86+
else
87+
echo "No schemas folder found at $parent_dir/schemas"
88+
fi
89+
7590
- name: Deploy to GitHub Pages
7691
uses: peaceiris/actions-gh-pages@v4
7792
with:
7893
github_token: ${{ secrets.GITHUB_TOKEN }}
7994
# Change the publish_dir to the folder you want served.
80-
# For example, here we deploy everything under "example_building_automation/api_docs"
81-
# which includes the generated swagger-ui subfolders.
95+
# Here we deploy the directory containing the generated swagger-ui (and now also the schemas folder, if available).
8296
publish_dir: ${{ matrix.output }}
83-
destination_dir: ${{ matrix.output }}
84-
85-
# - name: Commit generated Swagger UI files
86-
# run: |
87-
# git config --global user.name "github-actions[bot]"
88-
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
89-
# # Stage only changes in the api_docs folders
90-
# git add **/api_docs/swagger-ui
91-
# # Commit if there are changes
92-
# git commit -m "Update generated Swagger UI for ${{ matrix.spec }}" || echo "No changes to commit"
93-
# git push
94-
95-
# deploy-pages:
96-
# needs: update-docs
97-
# runs-on: ubuntu-latest
98-
# steps:
99-
# - name: Checkout repository
100-
# uses: actions/checkout@v2
101-
# with:
102-
# # Ensure the latest commits are checked out
103-
# fetch-depth: 0
104-
#
105-
# - name: Deploy to GitHub Pages
106-
# uses: peaceiris/actions-gh-pages@v3
107-
# with:
108-
# github_token: ${{ secrets.GITHUB_TOKEN }}
109-
# # Change the publish_dir to the folder you want served.
110-
# # For example, here we deploy everything under "example_building_automation/api_docs"
111-
# # which includes the generated swagger-ui subfolders.
112-
# publish_dir: example_building_automation/api_docs
97+
destination_dir: ${{ matrix.output }}

0 commit comments

Comments
 (0)