Skip to content

Commit

Permalink
ci+scripts: Pull sed invocations out into a script.
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Conrad <[email protected]>
  • Loading branch information
philipaconrad committed Apr 19, 2024
1 parent 5cd9b7a commit 8f792e3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/docfx-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,7 @@ jobs:
uses: actions/checkout@v3

- name: Patch Speakeasy README docs links
run: |
# OpaApiClient SDK
sed -i "s|(docs/sdks/opaapiclient/README.md)|(${{ steps.deployment.outputs.page_url }}/api/Styra.OpenApi.OpaApiClient.html)|g" README.md
# ExecutePolicy
sed -i "s|(docs/sdks/opaapiclient/README.md#executepolicy)|(${{ steps.deployment.outputs.page_url }}/api/Styra.OpenApi.OpaApiClient.html#Styra_OpenApi_OpaApiClient_ExecutePolicyAsync_Styra_OpenApi_Models_Requests_ExecutePolicyRequest_)|g" README.md
# ExecutePolicyWithInput
sed -i "s|(docs/sdks/opaapiclient/README.md#executepolicywithinput)|(${{ steps.deployment.outputs.page_url }}/api/Styra.OpenApi.OpaApiClient.html#Styra_OpenApi_OpaApiClient_ExecutePolicyWithInputAsync_Styra_OpenApi_Models_Requests_ExecutePolicyWithInputRequest_)|g" README.md
# Health
sed -i "s|(docs/sdks/opaapiclient/README.md#health)|(${{ steps.deployment.outputs.page_url }}/api/Styra.OpenApi.OpaApiClient.html#Styra_OpenApi_OpaApiClient_HealthAsync_System_Nullable_System_Boolean__System_Nullable_System_Boolean__System_Collections_Generic_List_System_String__)|g" README.md
run: ./scripts/patch-readme.sh README.md ${{ steps.deployment.outputs.page_url }}

- name: Dotnet Setup
uses: actions/setup-dotnet@v3
Expand Down
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_site/*
api/*
36 changes: 36 additions & 0 deletions scripts/patch-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# This script replaces Speakeasy's relative docs URLs with hyperlinks to
# appropriate DocFX docs for each class/method.

set -e

usage() {
echo "Usage:" >&2
echo " patch-readme.sh <FILENAME> <BASE_URL>" >&2
echo "Example:" >&2
echo " patch-readme.sh README.md http://localhost:8080/" >&2
}

# Ensure we have enough args.
if [[ $# -lt 2 ]]; then
echo "Not enough parameters provided." >&2
usage
exit 1
fi

# Ensure README file exists.
if [ ! -f $1 ]; then
echo "File '$1' not found!" >&2
usage
exit 1
fi

# OpaApiClient SDK
sed -i "s|(docs/sdks/opaapiclient/README.md)|($2/api/Styra.OpenApi.OpaApiClient.html)|g" $1
# ExecutePolicy
sed -i "s|(docs/sdks/opaapiclient/README.md#executepolicy)|($2/api/Styra.OpenApi.OpaApiClient.html#Styra_OpenApi_OpaApiClient_ExecutePolicyAsync_Styra_OpenApi_Models_Requests_ExecutePolicyRequest_)|g" $1
# ExecutePolicyWithInput
sed -i "s|(docs/sdks/opaapiclient/README.md#executepolicywithinput)|($2/api/Styra.OpenApi.OpaApiClient.html#Styra_OpenApi_OpaApiClient_ExecutePolicyWithInputAsync_Styra_OpenApi_Models_Requests_ExecutePolicyWithInputRequest_)|g" $1
# Health
sed -i "s|(docs/sdks/opaapiclient/README.md#health)|($2/api/Styra.OpenApi.OpaApiClient.html#Styra_OpenApi_OpaApiClient_HealthAsync_System_Nullable_System_Boolean__System_Nullable_System_Boolean__System_Collections_Generic_List_System_String__)|g" $1

0 comments on commit 8f792e3

Please sign in to comment.