Files
traefik-error-pages/.gitea/workflows/deploy.yml
T
feedc0de 4a68a78f0a
Validate and deploy error pages / Validate manifests (push) Failing after 25s
Validate and deploy error pages / Deploy to Kubernetes (push) Has been skipped
Initial commit
2026-08-08 20:42:38 +02:00

119 lines
5.0 KiB
YAML

name: Validate and deploy error pages
on:
push:
pull_request:
env:
HELM_VERSION: v4.2.2
KUBECTL_VERSION: v1.36.2
KUBERNETES_API: https://host.containers.internal:6443
KUBERNETES_TLS_SERVER_NAME: 192.168.0.2
NAMESPACE: default
RELEASE_NAME: traefik-error-pages
jobs:
validate:
name: Validate manifests
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Install Helm
run: |
curl --fail --silent --show-error --location \
--output "${RUNNER_TEMP}/helm.tar.gz" \
"https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz"
curl --fail --silent --show-error --location \
--output "${RUNNER_TEMP}/helm.tar.gz.sha256sum" \
"https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz.sha256sum"
(cd "${RUNNER_TEMP}" && sha256sum --check helm.tar.gz.sha256sum)
tar --extract --gzip --file "${RUNNER_TEMP}/helm.tar.gz" \
--directory "${RUNNER_TEMP}" linux-amd64/helm
mv "${RUNNER_TEMP}/linux-amd64/helm" "${RUNNER_TEMP}/helm"
chmod 0700 "${RUNNER_TEMP}/helm"
- name: Lint and render
run: |
"${RUNNER_TEMP}/helm" lint . --values values-brunner-ninja.yaml
"${RUNNER_TEMP}/helm" template "${RELEASE_NAME}" . \
--namespace "${NAMESPACE}" \
--values values-brunner-ninja.yaml > "${RUNNER_TEMP}/rendered.yaml"
test -s "${RUNNER_TEMP}/rendered.yaml"
deploy:
name: Deploy to Kubernetes
if: gitea.ref == 'refs/heads/main'
needs: validate
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Install Helm and kubectl
run: |
curl --fail --silent --show-error --location \
--output "${RUNNER_TEMP}/helm.tar.gz" \
"https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz"
curl --fail --silent --show-error --location \
--output "${RUNNER_TEMP}/helm.tar.gz.sha256sum" \
"https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz.sha256sum"
(cd "${RUNNER_TEMP}" && sha256sum --check helm.tar.gz.sha256sum)
tar --extract --gzip --file "${RUNNER_TEMP}/helm.tar.gz" \
--directory "${RUNNER_TEMP}" linux-amd64/helm
mv "${RUNNER_TEMP}/linux-amd64/helm" "${RUNNER_TEMP}/helm"
chmod 0700 "${RUNNER_TEMP}/helm"
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: Configure Kubernetes access
env:
KUBE_CONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64 }}
run: |
test -n "${KUBE_CONFIG_BASE64}"
printf '%s' "${KUBE_CONFIG_BASE64}" | base64 --decode > "${RUNNER_TEMP}/kubeconfig"
chmod 0600 "${RUNNER_TEMP}/kubeconfig"
export KUBECONFIG="${RUNNER_TEMP}/kubeconfig"
"${RUNNER_TEMP}/kubectl" config set-cluster cluster \
--server="${KUBERNETES_API}" \
--tls-server-name="${KUBERNETES_TLS_SERVER_NAME}"
- name: Apply and verify
run: |
export KUBECONFIG="${RUNNER_TEMP}/kubeconfig"
"${RUNNER_TEMP}/helm" template "${RELEASE_NAME}" . \
--namespace "${NAMESPACE}" \
--values values-brunner-ninja.yaml > "${RUNNER_TEMP}/rendered.yaml"
"${RUNNER_TEMP}/kubectl" apply \
--validate=false \
--filename "${RUNNER_TEMP}/rendered.yaml"
for attempt in {1..24}; do
IFS='|' read -r generation observed desired updated available unavailable <<< "$(
"${RUNNER_TEMP}/kubectl" --namespace "${NAMESPACE}" \
get deployment/traefik-error-pages \
--output=jsonpath='{.metadata.generation}|{.status.observedGeneration}|{.spec.replicas}|{.status.updatedReplicas}|{.status.availableReplicas}|{.status.unavailableReplicas}'
)"
echo "Rollout ${attempt}/24: generation ${observed}/${generation}, replicas ${updated}/${desired} updated, ${available}/${desired} available"
if [[ "${observed}" == "${generation}" \
&& "${updated}" == "${desired}" \
&& "${available}" == "${desired}" \
&& ( -z "${unavailable}" || "${unavailable}" == "0" ) ]]; then
echo "Error-page deployment successfully rolled out"
exit 0
fi
sleep 5
done
echo "Error-page rollout did not complete within two minutes" >&2
exit 1