This GitHub Action validates catalog metadata files against plugin package.json files to ensure consistency during the dynamic plugin export workflow.
For each YAML file in the metadata/ folder of the overlay workspace, the following checks are performed:
-
Package Exists: The
packageNamefield in the metadata must correspond to a plugin fromplugins-list.yamlwhosepackage.jsonhas a matchingnamefield -
Version Match: The
versionfield in the metadata matches theversionfield in the corresponding plugin'spackage.json -
OCI Reference Validation (if
dynamicArtifactstarts withoci://ghcr.io):- Tag Format: The image tag should be
bs_<target backstage version>__<plugin version> - Reference Format: The image reference (without tag) should be
<image repository prefix>/<package name with @ and / replaced by ->
- Tag Format: The image tag should be
-
Backstage Supported Versions Match: The
backstage.supportedVersionsfield in the metadata matches the major.minor version ofsupportedVersionsin the plugin'sdist-dynamic/package.json
- name: Validate Catalog Metadata
uses: redhat-developer/rhdh-plugin-export-utils/validate-metadata@main
with:
overlay-root: ${{ github.workspace }}/overlay-repo/workspaces/my-workspace
plugins-root: ${{ github.workspace }}/source-repo/workspaces/my-workspace
target-backstage-version: 1.42.5
image-repository-prefix: ghcr.io/my-org/my-repo # Optional| Input | Required | Default | Description |
|---|---|---|---|
overlay-root |
Yes | - | Absolute path to the overlay workspace folder containing metadata/ and plugins-list.yaml |
plugins-root |
Yes | - | Absolute path to the source plugins folder containing plugin directories with package.json files |
target-backstage-version |
Yes | - | Target Backstage version for validating OCI tag format (e.g., "1.42.5") |
image-repository-prefix |
No | "" |
Repository prefix for validating OCI reference format in dynamicArtifact |
| Output | Description |
|---|---|
validation-passed |
Whether the metadata validation passed (true/false) |
validation-errors |
JSON array of validation errors, empty array if validation passed |
validation-error-count |
Number of validation errors found |
The validation-errors output is a JSON array of error objects. Each error has a kind field that determines its structure:
{
"kind": "mismatch",
"file": "plugin-name.yaml",
"field": "version",
"expected": "1.2.3",
"actual": "1.2.0",
"message": "Version mismatch: expected \"1.2.3\" but got \"1.2.0\""
}{
"kind": "missing-field",
"file": "plugin-name.yaml",
"field": "spec",
"message": "Missing required field: spec"
}{
"kind": "missing-file",
"file": "metadata",
"message": "Metadata directory not found at /path/to/metadata"
}{
"kind": "parse-error",
"file": "plugin-name.yaml",
"message": "Failed to parse YAML"
}{
"kind": "unknown-package",
"file": "plugin-name.yaml",
"packageName": "@org/unknown-plugin",
"message": "Package \"@org/unknown-plugin\" not found in plugins-list.yaml"
}| Property | Description |
|---|---|
kind |
Error type: mismatch, missing-field, missing-file, parse-error, or unknown-package |
file |
Filename of the metadata file with the validation error |
message |
Human-readable description of the validation error |
When validation fails, the action:
- Writes to GitHub Step Summary: A detailed markdown table is added to the workflow summary showing all mismatches
- Sets Workflow Outputs: The validation errors are available as JSON for downstream steps
- Fails the Workflow: The step exits with a non-zero code, failing the workflow
The test/ directory contains fixtures for testing the validation action. The test workflow is located at .github/workflows/test-validate-metadata.yaml, which runs automatically on CI when changes are made to validate-metadata/**.
You can test the validation script directly:
cd validate-metadata
# Install dependencies
npm install
# Run validation (should pass)
INPUTS_OVERLAY_ROOT="$(pwd)/test/cases/pass" \
INPUTS_PLUGINS_ROOT="$(pwd)/test/source" \
INPUTS_IMAGE_REPOSITORY_PREFIX="ghcr.io/test-org/test-repo" \
INPUTS_TARGET_BACKSTAGE_VERSION="1.42.5" \
node validate-metadata.tsYou can use act to run the test workflow locally:
# Run all test jobs
act -W .github/workflows/test-validate-metadata.yaml
# Run a specific test job (e.g., test-validation-pass)
act -j test-validation-pass -W .github/workflows/test-validate-metadata.yamlSee .github/workflows/test-validate-metadata.yaml for available test jobs.