diff --git a/README.md b/README.md index 9688bfc..8997277 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Add the following steps to your GitHub workflow, replacing the input values: ] # Parent directory to use for generated API docs HTML api-docs-dir: 'YOUR_API_DOCS_FILEPATH' + workspace-dir: 'OPTIONAL_RELATIVE_PATH_TO_THE_OPENAPI_SCHEMA' ``` ## Scenarios diff --git a/action.yml b/action.yml index bcb6c7a..2c4560b 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,9 @@ inputs: api-docs-dir: description: Parent directory to use for API docs required: true + src-dir: + description: Optional directory to run the generation script from + required: false # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. @@ -57,6 +60,8 @@ runs: GH_TOKEN: ${{ github.token }} # Used to return to caller's repository directory WORKSPACE_DIR: ${{ github.workspace }} + # Used for multi-file API specs, run the script from this directory to correctly resolve relative paths in references + SRC_DIR: ${{ inputs.src-dir }} - name: Set up GitHub Pages uses: actions/configure-pages@v5 - name: Upload API docs to GitHub Pages diff --git a/scripts/generate-single-spec-doc.sh b/scripts/generate-single-spec-doc.sh index fbc51db..b2e31d8 100644 --- a/scripts/generate-single-spec-doc.sh +++ b/scripts/generate-single-spec-doc.sh @@ -56,6 +56,12 @@ else $apiSpecFetchUri > $openApiJsonFilepath fi +# Go to the source directory if provided +if [ -n "$SRC_DIR" ]; then + echo "Changing directory to SRC_DIR: $SRC_DIR" + cd "${SRC_DIR}" +fi + # Validate OpenAPI JSON spec exists if [ ! -f "$openApiJsonFilepath" ]; then echo "Failed to generate API documentation since API spec was not found at $openApiJsonFilepath"