-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to update API docs for releases.
- Loading branch information
1 parent
d06a113
commit df88a94
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: "Publish Versioned API Reference Wiki page" | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
publish-versioned-api-reference: | ||
name: Publish Versioned API Reference Wiki | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout operator codebase | ||
uses: actions/checkout@v2 | ||
with: | ||
path: messaging-topology-operator | ||
- name: Get the version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
- name: Checkout wiki codebase | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: ${{ github.repository }}.wiki | ||
path: wiki | ||
- name: Push to wiki | ||
run: | | ||
cd wiki | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "github-actions" | ||
# Add the versioned API Reference to the Wiki | ||
cp ../messaging-topology-operator/docs/api/rabbitmq.com.ref.asciidoc ./API_Reference_${{ steps.get_version.outputs.VERSION }}.asciidoc | ||
# Regenerate the ordered list of API Reference docs for the sidebar | ||
export REGENERATED_SIDEBAR="$(../messaging-topology-operator/hack/generate-ordered-api-reference-list.sh .)" | ||
echo "$REGENERATED_SIDEBAR" > Wiki_Sidebar.md | ||
git add ./API_Reference_${{ steps.get_version.outputs.VERSION }}.asciidoc | ||
git add ./Wiki_Sidebar.md | ||
git commit -m "Publish version ${{ steps.get_version.outputs.VERSION }} API Reference" && git push | ||
- uses: 8398a7/action-slack@v3 | ||
with: | ||
status: ${{ job.status }} | ||
fields: repo,message,action,eventName | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
if: failure() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
wikiDir=$1 | ||
|
||
generateVersionedEntry() { | ||
echo "* [$1](https://github.com/rabbitmq/messaging-topology-operator/wiki/API_Reference_$1)" | ||
} | ||
|
||
generateLatestEntry() { | ||
echo "* [Latest](https://github.com/rabbitmq/messaging-topology-operator/wiki/API_Reference)" | ||
} | ||
|
||
lead='^<!--- BEGIN API REFERENCE LIST -->$' | ||
tail='^<!--- END API REFERENCE LIST -->$' | ||
|
||
unorderedlistfile="$(mktemp)" | ||
orderedlistfile="$(mktemp)" | ||
|
||
apiVersions="$(find "$wikiDir/API_Reference_*" -printf "%f\n" | sed -r 's/API_Reference_(v[0-9]+.[0-9]+.[0-9]+).asciidoc/\1/' | sort -Vr )" | ||
for version in $apiVersions | ||
do | ||
generateVersionedEntry "$version" >> "$unorderedlistfile" | ||
done | ||
|
||
# Latest API version is a special case, that is always top of the list | ||
generateLatestEntry > "$orderedlistfile" | ||
cat "$unorderedlistfile" >> "$orderedlistfile" | ||
|
||
sed -e "/$lead/,/$tail/{ /$lead/{p; r $orderedlistfile | ||
}; /$tail/p; d }" "$wikiDir/Wiki_Sidebar.md" |