Skip to content

Commit dff911c

Browse files
michalby24michalby24netanelC
authored
ci(validate-domain): create action (#98)
* feat(ci): add init action * feat: add test workflow for validating domain action * feat: add validation workflow for Helm chart domain annotation * Update actions/validate-domain/README.md Co-authored-by: Netanel Cohen <34451523+netanelC@users.noreply.github.com> * Update .github/workflows/test-validate-domain.yaml Co-authored-by: Netanel Cohen <34451523+netanelC@users.noreply.github.com> * feat: add validate-domain action configuration to release-please * fix: update validate-domain action to remove allowed-domains input and use constant list * docs: update README to include release-please versioning markers --------- Co-authored-by: michalby24 <michalby24@gmail.com> Co-authored-by: Netanel Cohen <34451523+netanelC@users.noreply.github.com>
1 parent 79b1744 commit dff911c

5 files changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: test-validate-domain
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "actions/validate-domain/**"
7+
8+
jobs:
9+
validate-domain:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v5
14+
15+
- name: Test validate domain action
16+
uses: ./actions/validate-domain
17+
with:
18+
chart-file: test/helm/Chart.yaml

actions/validate-domain/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# validate-domain
2+
3+
Validate that a Helm chart (`Chart.yaml`) contains an `annotations.domain` value that is one of a configured set of allowed domains.
4+
5+
## ✨ What It Does
6+
7+
The action:
8+
Checks if the `Chart.yaml` has the "domain" annotation and validates that the domain is in the domains list
9+
10+
## Inputs
11+
12+
| Name | Required | Default | Description |
13+
|------|----------|---------|-------------|
14+
| `chart-file` | no | `helm/Chart.yaml` | Path to the Helm chart file whose `annotations.domain` will be validated. |
15+
16+
The set of allowed domains is constant (not configurable):
17+
18+
```
19+
raster, vector, infra, 3d, app, dem, common
20+
```
21+
22+
If you need to change or extend this list, update the action source or open a PR.
23+
24+
25+
## 🚀 Usage
26+
27+
<!-- x-release-please-start-version -->
28+
```yaml
29+
- name: Validate domain
30+
uses: MapColonies/shared-workflows/actions/validate-domain@v1
31+
```
32+
<!-- x-release-please-end-version -->
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: validate-domain
2+
description: "Validate that helm/Chart.yaml contains annotations.domain with an allowed value"
3+
4+
inputs:
5+
chart-file:
6+
description: "Path to Chart.yaml"
7+
required: false
8+
default: "helm/Chart.yaml"
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Read domain annotation from Chart.yaml
14+
id: get_domain
15+
uses: mikefarah/yq@v4.48.2
16+
with:
17+
cmd: yq e '.annotations.domain' "${{ inputs.chart-file }}"
18+
19+
- name: Validate domain
20+
env:
21+
ALLOWED_DOMAINS: "raster,vector,infra,3d,app,dem,common"
22+
shell: bash
23+
run: |
24+
DOMAIN="${{ steps.get_domain.outputs.result }}"
25+
IFS=',' read -ra ALLOWED <<< "${{ env.ALLOWED_DOMAINS }}"
26+
27+
if ! printf "%s\n" "${ALLOWED[@]}" | grep -qx "$DOMAIN"; then
28+
echo "Invalid domain: $DOMAIN"
29+
exit 1
30+
fi

release-please-config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@
6868
"release-type": "simple",
6969
"package-name": "init-npm",
7070
"extra-files": ["README.md"]
71+
},
72+
"actions/validate-domain": {
73+
"release-type": "simple",
74+
"package-name": "validate-domain",
75+
"extra-files": ["README.md"]
7176
}
7277
}
7378
}

test/helm/Chart.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
apiVersion: v2
22
name: hello-world-chart
3+
annotations:
4+
domain: common
35
description: A Helm chart for Kubernetes
46
type: application
57
version: 6.0.0

0 commit comments

Comments
 (0)