Skip to content

Commit

Permalink
Merge pull request #207 from port-labs/docs_ci
Browse files Browse the repository at this point in the history
Docs CI
  • Loading branch information
OmriGez authored Feb 2, 2025
2 parents 7a63acd + a0b8bf9 commit 60fe600
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docs-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Validate Documentation

on:
pull_request:

jobs:
docs-check:
name: Check Documentation Matches Provider Schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true

- name: Install tfplugindocs
run: make setup

- name: Generate Documentation
run: make gen-docs

- name: Check for changes in docs
run: |
DOCS_CHANGES=$(git status --porcelain docs/)
if [[ -n "${DOCS_CHANGES}" ]]; then
echo "Error: Documentation is out of sync with schema. Please run 'make gen-docs' locally and commit the changes."
echo "Changes detected in docs folder:"
echo "${DOCS_CHANGES}"
exit 1
fi
6 changes: 5 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ make lint
**NOTE**: Should be installed with `make dev-setup`, if you prefer manually, have a look at the [installation guide](https://golangci-lint.run/welcome/install/#local-installation).


In addition, when changing documentation, run `make gen-docs`.
## Documentation

The resource examples are generated from the schema. This means that in order to update the examples, you will need to update the `ResourceMarkdownDescription` in the resource schema.go file.

In addition, when changing schema, run `make gen-docs`.

You can preview how the documentation will look in the Terraform registry with [this tool](https://registry.terraform.io/tools/doc-preview).

Expand Down
1 change: 1 addition & 0 deletions docs/resources/port_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ Optional:
- `properties` (String) The properties of the entity (key-value object encoded to a string)
- `relations` (String) The relations of the entity (key-value object encoded to a string)
- `teams` (List of String) The teams the entity belongs to
- `teams_jq` (String) Jq that returns the teams the entity belongs to



Expand Down
20 changes: 0 additions & 20 deletions docs/resources/port_blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,6 @@ resource "port_blueprint" "environment" {
```

## Example Usage with String Array Pattern Validation

```hcl
resource "port_blueprint" "regex" {
title = "Regex"
identifier = "regex"
properties = {
array_props = {
"stringArrayProp" = {
title = "String Array"
string_items = {
pattern = "^[a-zA-Z0-9]*$"
default = ["abc", "123", "test"]
}
}
}
}
}
```

## Example Usage with Relations

```hcl
Expand Down
19 changes: 12 additions & 7 deletions docs/resources/port_scorecard.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ description: |-
]
}
```
Example Usage with Levels
Example Usage with Levels and Filter
This will override the default levels (Basic, Bronze, Silver, Gold) with the provided levels: Not Ready, Partially Ready, Ready.
```hcl
resource "portblueprint" "microservice" {
Expand Down Expand Up @@ -130,6 +130,16 @@ description: |-
identifier = "Readiness"
title = "Readiness"
blueprint = portblueprint.microservice.identifier
filter = {
combinator = "and"
conditions = [
jsonencode({
property = "sum"
operator = ">"
value = 0
})
]
}
levels = [
{
color = "red"
Expand Down Expand Up @@ -352,15 +362,10 @@ resource "port_scorecard" "readiness" {
filter = {
combinator = "and"
conditions = [
jsonencode({
property = "required"
operator = "="
value = true
}),
jsonencode({
property = "sum"
operator = ">"
value = 5
value = 0
})
]
}
Expand Down
12 changes: 11 additions & 1 deletion port/scorecard/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ resource "port_scorecard" "readiness" {
` + "```" + `
## Example Usage with Levels
## Example Usage with Levels and Filter
This will override the default levels (Basic, Bronze, Silver, Gold) with the provided levels: Not Ready, Partially Ready, Ready.
Expand Down Expand Up @@ -295,6 +295,16 @@ resource "port_scorecard" "readiness" {
identifier = "Readiness"
title = "Readiness"
blueprint = port_blueprint.microservice.identifier
filter = {
combinator = "and"
conditions = [
jsonencode({
property = "sum"
operator = ">"
value = 0
})
]
}
levels = [
{
color = "red"
Expand Down

0 comments on commit 60fe600

Please sign in to comment.