Skip to content

Commit 2989e4a

Browse files
authored
Adds github task to ensure api-docs stay up to date (#115)
* Update api-docs by re-running make task - Adds the OCIRepositoryGenerator * Adds build-docs task
1 parent 794c408 commit 2989e4a

File tree

3 files changed

+194
-71
lines changed

3 files changed

+194
-71
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,30 @@ jobs:
4343
- name: Test
4444
run: make test
4545

46+
build-docs:
47+
runs-on: ubuntu-latest
48+
permissions:
49+
contents: read # for actions/checkout to fetch code
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
with:
54+
fetch-depth: 0 # for git describe
55+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
56+
57+
- name: Build docs
58+
run: |
59+
make api-docs
60+
if [[ -n $(git status --porcelain) ]]; then
61+
echo ""
62+
echo "Docs are out of date!"
63+
echo "The following files have changed:"
64+
git status --porcelain
65+
echo "Please run 'make api-docs' and commit the changes."
66+
echo "If it was something unrelated to the docs, that is strange... scope down this check or commit those files too?"
67+
exit 1
68+
fi
69+
4670
build:
4771
runs-on: ubuntu-latest
4872
permissions:

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ help: ## Display this help.
4646
##@ Development
4747

4848
.PHONY: manifests
49-
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
49+
manifests: api-docs controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
5050
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
5151

5252
.PHONY: generate
@@ -216,9 +216,10 @@ gen-crd-api-reference-docs: ## Download gen-crd-api-reference-docs locally if ne
216216

217217
api-docs: gen-crd-api-reference-docs ## Generate API reference documentation
218218
$(GEN_CRD_API_REFERENCE_DOCS) -api-dir=./api/v1alpha1 -config=./hack/api-docs/config.json -template-dir=./hack/api-docs/template -out-file=./docs/api/gitopsset.md
219-
@sed -i '' -e 's/<namespace><em><name><\/em><group>_<kind>/namespace_name_group_kind/g' docs/api/gitopsset.md
220-
221-
219+
@uname -s | grep -q Darwin && \
220+
sed -i '' -e 's/<namespace><em><name><\/em><group>_<kind>/namespace_name_group_kind/g' docs/api/gitopsset.md || \
221+
sed -i -e 's/<namespace><em><name><\/em><group>_<kind>/namespace_name_group_kind/g' docs/api/gitopsset.md
222+
222223
user-guide: api-docs
223224
cp ./docs/README.md ../weave-gitops/website/docs/gitopssets/guide.mdx
224225
cp ./docs/api/gitopsset.md ../weave-gitops/website/docs/gitopssets/_api.mdx

0 commit comments

Comments
 (0)