Skip to content
Merged
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
18 changes: 18 additions & 0 deletions .github/workflows/test-validate-domain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: test-validate-domain

on:
pull_request:
paths:
- "actions/validate-domain/**"

jobs:
validate-domain:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Test validate domain action
uses: ./actions/validate-domain
with:
chart-file: test/helm/Chart.yaml
32 changes: 32 additions & 0 deletions actions/validate-domain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# validate-domain

Validate that a Helm chart (`Chart.yaml`) contains an `annotations.domain` value that is one of a configured set of allowed domains.

## ✨ What It Does

The action:
Checks if the `Chart.yaml` has the "domain" annotation and validates that the domain is in the domains list

## Inputs

| Name | Required | Default | Description |
|------|----------|---------|-------------|
| `chart-file` | no | `helm/Chart.yaml` | Path to the Helm chart file whose `annotations.domain` will be validated. |

The set of allowed domains is constant (not configurable):

```
raster, vector, infra, 3d, app, dem, common
```

If you need to change or extend this list, update the action source or open a PR.


## 🚀 Usage

<!-- x-release-please-start-version -->
```yaml
- name: Validate domain
uses: MapColonies/shared-workflows/actions/validate-domain@v1
```
<!-- x-release-please-end-version -->
30 changes: 30 additions & 0 deletions actions/validate-domain/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: validate-domain
description: "Validate that helm/Chart.yaml contains annotations.domain with an allowed value"

inputs:
chart-file:
description: "Path to Chart.yaml"
required: false
default: "helm/Chart.yaml"

runs:
using: composite
steps:
- name: Read domain annotation from Chart.yaml
id: get_domain
uses: mikefarah/yq@v4.48.2
with:
cmd: yq e '.annotations.domain' "${{ inputs.chart-file }}"

- name: Validate domain
env:
ALLOWED_DOMAINS: "raster,vector,infra,3d,app,dem,common"
shell: bash
run: |
DOMAIN="${{ steps.get_domain.outputs.result }}"
IFS=',' read -ra ALLOWED <<< "${{ env.ALLOWED_DOMAINS }}"

if ! printf "%s\n" "${ALLOWED[@]}" | grep -qx "$DOMAIN"; then
echo "Invalid domain: $DOMAIN"
exit 1
fi
5 changes: 5 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
"release-type": "simple",
"package-name": "init-npm",
"extra-files": ["README.md"]
},
"actions/validate-domain": {
"release-type": "simple",
"package-name": "validate-domain",
"extra-files": ["README.md"]
}
}
}
2 changes: 2 additions & 0 deletions test/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apiVersion: v2
name: hello-world-chart
annotations:
domain: common
description: A Helm chart for Kubernetes
type: application
version: 6.0.0
Expand Down