Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/template_backstage_entity_validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Backstage Entity Validation

on:
workflow_call:
inputs:
path:
default: "catalog-info.yaml"
required: false
type: string
custom-schema-url:
default: https://raw.githubusercontent.com/Staffbase/gha-workflows/refs/heads/main/schemas/custom-catalog-info.schema.json
required: false
type: string

jobs:
validation:
name: Validate Backstage Entities
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

# Download the schema file
- name: Download custom schema file
if: ${{ inputs.custom-schema-url }} != ""
run: |
curl -o custom-catalog-info.schema.json ${{ inputs.custom-schema-url }}
# Set the schema file location
echo "schema-file-location=custom-catalog-info.schema.json" >> $GITHUB_OUTPUT

- name: Validate Backstage Entities
uses: RoadieHQ/backstage-entity-validator@v0.5.0
with:
path: ${{ inputs.path }}
validationSchemaFileLocation: custom-catalog-info.schema.json
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ jobs:

</details>

### Backstage Entity Validation

<details>
<summary>The action can be used to validate the Backstage entity files.</summary>

```yml
name: Backstage Entity Validation
on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
validation:
uses: Staffbase/gha-workflows/.github/workflows/template_backstage_entity_validation.yml@v7.2.0
```

### Changeset Check

<details>
Expand Down
78 changes: 78 additions & 0 deletions schemas/custom-catalog-info.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "ApiV1alpha1",
"description": "An API describes an interface that can be exposed by a component. The API can be defined in different formats, like OpenAPI, AsyncAPI, GraphQL, gRPC, or other formats.",
"examples": [
{
"apiVersion": "backstage.io/v1alpha1",
"kind": "API",
"metadata": {
"name": "artist-api",
"description": "Retrieve artist details",
"labels": {
"product_name": "Random value Generator"
},
"annotations": {
"docs": "https://github.com/..../tree/develop/doc"
}
},
"spec": {
"type": "openapi",
"lifecycle": "production",
"system": "artist-engagement-portal",
"definition": "openapi: \"3.0.0\"\ninfo:..."
}
}
],
"allOf": [
{
"$ref": "Entity"
},
{
"type": "object",
"required": ["spec"],
"properties": {
"apiVersion": {
"enum": ["backstage.io/v1alpha1", "backstage.io/v1beta1"]
},
"kind": {
"enum": ["API"]
},
"spec": {
"type": "object",
"required": ["type", "lifecycle", "definition"],
"properties": {
"type": {
"type": "string",
"description": "The type of the API definition.",
"examples": ["openapi", "asyncapi", "graphql", "grpc", "trpc"],
"minLength": 1
},
"lifecycle": {
"type": "string",
"description": "The lifecycle state of the API.",
"examples": ["experimental", "production", "deprecated"],
"minLength": 1
},
"owner": {
"type": "string",
"description": "An entity reference to the owner of the API.",
"examples": ["artist-relations-team", "user:john.johnson"],
"minLength": 1
},
"system": {
"type": "string",
"description": "An entity reference to the system that the API belongs to.",
"minLength": 1
},
"definition": {
"type": "string",
"description": "The definition of the API, based on the format defined by the type.",
"minLength": 1
}
}
}
}
}
]
}