Files
feedc0de 35ae5557b9
Validate and deploy Plex / Validate manifests and scripts (push) Successful in 12s
Validate and deploy Plex / Deploy to Kubernetes (push) Successful in 18s
Initial commit with the existing deployment files
2026-10-09 09:09:31 +02:00

77 lines
3.3 KiB
YAML

name: Validate and deploy Plex
on:
push:
pull_request:
env:
KUBECTL_VERSION: v1.36.4
KUBERNETES_API: https://host.containers.internal:6443
KUBERNETES_TLS_SERVER_NAME: 192.168.0.2
jobs:
validate:
name: Validate manifests and scripts
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
- name: Validate
run: ./test.sh
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 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: 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
env:
COMMIT_SHA: ${{ gitea.sha }}
run: |
set -euo pipefail
export KUBECONFIG="${RUNNER_TEMP}/kubeconfig"
sed "s|deployment.brunner.ninja/revision: manual|deployment.brunner.ninja/revision: ${COMMIT_SHA}|" \
plex.yaml > "${RUNNER_TEMP}/plex.yaml"
"${RUNNER_TEMP}/kubectl" apply --dry-run=server --validate=false \
--filename "${RUNNER_TEMP}/plex.yaml"
"${RUNNER_TEMP}/kubectl" apply --validate=false \
--filename "${RUNNER_TEMP}/plex.yaml"
for attempt in {1..180}; do
IFS='|' read -r generation observed desired updated ready available image <<< "$(
"${RUNNER_TEMP}/kubectl" --namespace plex get deployment/plex \
--output=jsonpath='{.metadata.generation}|{.status.observedGeneration}|{.spec.replicas}|{.status.updatedReplicas}|{.status.readyReplicas}|{.status.availableReplicas}|{.spec.template.spec.containers[?(@.name=="plex")].image}'
)"
echo "Rollout ${attempt}/180: generation ${observed}/${generation}, replicas ${updated}/${desired} updated, ${ready}/${desired} ready, ${available}/${desired} available, image ${image}"
if [[ "${observed}" == "${generation}" && "${updated}" == "${desired}" \
&& "${ready}" == "${desired}" && "${available}" == "${desired}" ]]; then
exit 0
fi
sleep 5
done
"${RUNNER_TEMP}/kubectl" --namespace plex get deployment/plex --output=yaml
exit 1