Trying to fix CI/CD
This commit is contained in:
1 parent
e05116dd1e
commit
0293469f5f
3 files changed
+26
-27
No files matched your search
@@ -5,6 +5,7 @@ on:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
KUBECONFORM_VERSION: v0.7.0
|
||||
KUBECTL_VERSION: v1.36.3
|
||||
KUBERNETES_API: https://host.containers.internal:6443
|
||||
KUBERNETES_TLS_SERVER_NAME: 192.168.0.2
|
||||
@@ -18,25 +19,16 @@ jobs:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install kubectl
|
||||
run: |
|
||||
curl --fail --silent --show-error --location \
|
||||
--output "${RUNNER_TEMP}/kubectl" \
|
||||
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
|
||||
curl --fail --silent --show-error --location \
|
||||
--output "${RUNNER_TEMP}/kubectl.sha256" \
|
||||
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
|
||||
printf '%s %s\n' "$(cat "${RUNNER_TEMP}/kubectl.sha256")" "${RUNNER_TEMP}/kubectl" | sha256sum --check
|
||||
chmod 0700 "${RUNNER_TEMP}/kubectl"
|
||||
|
||||
- name: Validate scripts and Kubernetes resources
|
||||
run: |
|
||||
sh -n install.sh
|
||||
bash -n create-ci-kubeconfig.sh
|
||||
"${RUNNER_TEMP}/kubectl" create \
|
||||
--dry-run=client \
|
||||
--validate=false \
|
||||
--filename mumble.yaml >/dev/null
|
||||
docker run --rm --interactive \
|
||||
"ghcr.io/yannh/kubeconform:${KUBECONFORM_VERSION}@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c" \
|
||||
-strict -summary < mumble.yaml
|
||||
docker run --rm --interactive \
|
||||
"ghcr.io/yannh/kubeconform:${KUBECONFORM_VERSION}@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c" \
|
||||
-strict -summary < ci-deployer.yaml
|
||||
|
||||
deploy:
|
||||
name: Deploy to Kubernetes
|
||||
|
||||
@@ -28,7 +28,7 @@ configuration is supplied through environment variables.
|
||||
- `mumble.yaml`: LoadBalancer Service and Mumble Deployment.
|
||||
- `install.sh`: administrator installation, credential generation, idempotent
|
||||
PostgreSQL bootstrap, and rollout verification.
|
||||
- `test.sh`: local syntax and client-side Kubernetes validation.
|
||||
- `test.sh`: local script and offline Kubernetes schema validation.
|
||||
- `ci-deployer.yaml`: restricted Gitea Actions ServiceAccount, Role, binding,
|
||||
and revocable token request.
|
||||
- `create-ci-kubeconfig.sh`: one-time CI identity bootstrap.
|
||||
@@ -99,8 +99,10 @@ when it starts. Its channels and registrations remain in PostgreSQL.
|
||||
./test.sh
|
||||
```
|
||||
|
||||
The test checks both shell scripts and parses the Kubernetes resources without
|
||||
contacting the cluster.
|
||||
The test checks both shell scripts and validates the Kubernetes resources with
|
||||
kubeconform without contacting the cluster. It uses a locally installed
|
||||
kubeconform binary when available, otherwise the official
|
||||
`ghcr.io/yannh/kubeconform:v0.7.0` container, pinned by digest, through Docker.
|
||||
|
||||
## Automatic deployment with Gitea Actions
|
||||
|
||||
|
||||
@@ -4,16 +4,21 @@ set -euo pipefail
|
||||
|
||||
project_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
command -v kubectl >/dev/null 2>&1 || {
|
||||
echo "Required command not found: kubectl" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
sh -n "${project_dir}/install.sh"
|
||||
bash -n "${project_dir}/create-ci-kubeconfig.sh"
|
||||
kubectl create \
|
||||
--dry-run=client \
|
||||
--validate=false \
|
||||
--filename "${project_dir}/mumble.yaml" >/dev/null
|
||||
|
||||
if command -v kubeconform >/dev/null 2>&1; then
|
||||
kubeconform -strict -summary "${project_dir}/mumble.yaml" "${project_dir}/ci-deployer.yaml"
|
||||
elif command -v docker >/dev/null 2>&1; then
|
||||
docker run --rm --interactive \
|
||||
ghcr.io/yannh/kubeconform:v0.7.0@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c \
|
||||
-strict -summary < "${project_dir}/mumble.yaml"
|
||||
docker run --rm --interactive \
|
||||
ghcr.io/yannh/kubeconform:v0.7.0@sha256:85dbef6b4b312b99133decc9c6fc9495e9fc5f92293d4ff3b7e1b30f5611823c \
|
||||
-strict -summary < "${project_dir}/ci-deployer.yaml"
|
||||
else
|
||||
echo "Required command not found: install kubeconform or Docker" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Mumble scripts and Kubernetes resources are valid."
|
||||
Reference in new issue
Block a user