|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + # ── Job 1: Helm lint & render ────────────────────────────────────────────── |
| 11 | + helm-lint: |
| 12 | + name: Helm lint |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Install Helm |
| 18 | + uses: azure/setup-helm@v4 |
| 19 | + with: |
| 20 | + version: "latest" |
| 21 | + |
| 22 | + - name: Lint openbao-init (local values) |
| 23 | + run: helm lint apps/openbao-init/ -f apps/openbao-init/values-local.yaml |
| 24 | + |
| 25 | + - name: Lint openbao-init (scaleway values) |
| 26 | + run: helm lint apps/openbao-init/ -f apps/openbao-init/values-scaleway.yaml |
| 27 | + |
| 28 | + - name: Render bootstrap chart (local) |
| 29 | + run: helm template boot bootstrap/ --set env=local --set revision=main |
| 30 | + |
| 31 | + - name: Render clusters/local chart |
| 32 | + run: helm template loc clusters/local/ --set revision=main |
| 33 | + |
| 34 | + - name: Render clusters/scaleway chart |
| 35 | + run: helm template loc clusters/scaleway/ --set revision=main |
| 36 | + |
| 37 | + # ── Job 2: Infisical absent ──────────────────────────────────────────────── |
| 38 | + infisical-absent: |
| 39 | + name: Infisical absent |
| 40 | + runs-on: ubuntu-latest |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Assert no Infisical references in active GitOps manifests |
| 45 | + run: | |
| 46 | + if git grep -ri infisical apps/ platform/ clusters/ bootstrap/ 2>/dev/null; then |
| 47 | + echo "ERROR: Infisical references found in GitOps manifests" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + echo "OK: No Infisical references found" |
| 51 | +
|
| 52 | + # ── Job 3: Secrets restore (destroy/recreate) ────────────────────────────── |
| 53 | + secrets-restore: |
| 54 | + name: Secrets restore |
| 55 | + runs-on: ubuntu-latest |
| 56 | + environment: dev |
| 57 | + env: |
| 58 | + ARGOCD_VERSION: "v2.13.0" |
| 59 | + BAO_VERSION: "2.0.3" |
| 60 | + REPO_URL: https://github.com/${{ github.repository }} |
| 61 | + BRANCH: ${{ github.head_ref || github.ref_name }} |
| 62 | + |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Install Helm |
| 67 | + uses: azure/setup-helm@v4 |
| 68 | + with: |
| 69 | + version: "latest" |
| 70 | + |
| 71 | + - name: Install bao CLI |
| 72 | + run: | |
| 73 | + curl -sSfL \ |
| 74 | + "https://github.com/openbao/openbao/releases/download/v${BAO_VERSION}/bao_${BAO_VERSION}_linux_amd64.zip" \ |
| 75 | + -o bao.zip |
| 76 | + unzip -q bao.zip bao |
| 77 | + sudo mv bao /usr/local/bin/bao |
| 78 | +
|
| 79 | + - name: Start minikube |
| 80 | + uses: medyagh/setup-minikube@latest |
| 81 | + |
| 82 | + - name: Install ArgoCD |
| 83 | + run: | |
| 84 | + kubectl create namespace argocd |
| 85 | + kubectl apply -n argocd \ |
| 86 | + -f "https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml" |
| 87 | + kubectl rollout status deployment/argocd-server -n argocd --timeout=180s |
| 88 | +
|
| 89 | + - name: Expose ArgoCD + login |
| 90 | + id: argocd-login |
| 91 | + run: | |
| 92 | + kubectl port-forward svc/argocd-server -n argocd 8080:443 & |
| 93 | + sleep 8 |
| 94 | + PASS=$(kubectl -n argocd get secret argocd-initial-admin-secret \ |
| 95 | + -o jsonpath="{.data.password}" | base64 -d) |
| 96 | + argocd login localhost:8080 --username admin --password "${PASS}" --insecure |
| 97 | + # Allow ArgoCD to pull from this (possibly private) repo via GITHUB_TOKEN |
| 98 | + argocd repo add "${REPO_URL}" \ |
| 99 | + --username x-access-token \ |
| 100 | + --password "${{ secrets.GITHUB_TOKEN }}" \ |
| 101 | + --insecure-skip-server-verification || true |
| 102 | +
|
| 103 | + - name: Inject S3 credentials Secret (pre-sync) |
| 104 | + run: | |
| 105 | + kubectl create namespace openbao --dry-run=client -o yaml | kubectl apply -f - |
| 106 | + kubectl create secret generic scaleway-s3-credentials \ |
| 107 | + --namespace openbao \ |
| 108 | + --from-literal=access_key="${{ secrets.SCW_ACCESS_KEY }}" \ |
| 109 | + --from-literal=secret_key="${{ secrets.SCW_SECRET_KEY }}" \ |
| 110 | + --from-literal=bucket="${{ vars.SCW_S3_BUCKET }}" |
| 111 | +
|
| 112 | + - name: Apply bootstrap Application |
| 113 | + run: | |
| 114 | + argocd app create bootstrap \ |
| 115 | + --repo "${REPO_URL}" \ |
| 116 | + --path bootstrap \ |
| 117 | + --dest-server https://kubernetes.default.svc \ |
| 118 | + --dest-namespace argocd \ |
| 119 | + --helm-set env=local \ |
| 120 | + --helm-set "revision=${BRANCH}" \ |
| 121 | + --helm-set "repoURL=${REPO_URL}" \ |
| 122 | + --sync-policy automated \ |
| 123 | + --upsert |
| 124 | +
|
| 125 | + - name: Wait for OpenBao to unseal |
| 126 | + id: wait-unseal |
| 127 | + run: | |
| 128 | + # Poll health endpoint until initialized + unsealed (HTTP 200) |
| 129 | + BAO_ADDR="http://$(kubectl get svc openbao -n openbao \ |
| 130 | + -o jsonpath='{.spec.clusterIP}' 2>/dev/null || echo 'pending'):8200" |
| 131 | + echo "BAO_ADDR=${BAO_ADDR}" >> "${GITHUB_ENV}" |
| 132 | +
|
| 133 | + for i in $(seq 1 72); do |
| 134 | + # Refresh ClusterIP in case the svc wasn't ready yet |
| 135 | + CIP=$(kubectl get svc openbao -n openbao -o jsonpath='{.spec.clusterIP}' 2>/dev/null || true) |
| 136 | + if [ -n "${CIP}" ]; then |
| 137 | + BAO_ADDR="http://${CIP}:8200" |
| 138 | + echo "BAO_ADDR=${BAO_ADDR}" >> "${GITHUB_ENV}" |
| 139 | + fi |
| 140 | +
|
| 141 | + STATUS=$(curl -sf -o /dev/null -w "%{http_code}" \ |
| 142 | + "${BAO_ADDR}/v1/sys/health" 2>/dev/null || echo "000") |
| 143 | + echo "Attempt ${i}/72 — OpenBao status: ${STATUS}" |
| 144 | +
|
| 145 | + if [ "${STATUS}" = "200" ] || [ "${STATUS}" = "429" ]; then |
| 146 | + echo "OpenBao is unsealed." |
| 147 | + break |
| 148 | + fi |
| 149 | + sleep 5 |
| 150 | + done |
| 151 | +
|
| 152 | + if [ "${STATUS}" != "200" ] && [ "${STATUS}" != "429" ]; then |
| 153 | + echo "ERROR: OpenBao did not unseal within 6 minutes" |
| 154 | + kubectl get events -n openbao --sort-by='.lastTimestamp' | tail -20 || true |
| 155 | + kubectl logs -l 'app.kubernetes.io/name=openbao' -n openbao --tail=50 || true |
| 156 | + exit 1 |
| 157 | + fi |
| 158 | +
|
| 159 | + - name: Write canary secret |
| 160 | + run: | |
| 161 | + CANARY_VALUE="survive-${{ github.run_id }}" |
| 162 | + echo "CANARY_VALUE=${CANARY_VALUE}" >> "${GITHUB_ENV}" |
| 163 | +
|
| 164 | + # Authenticate via Kubernetes auth using the external-secrets SA token |
| 165 | + SA_JWT=$(kubectl create token external-secrets -n external-secrets --duration=5m) |
| 166 | + BAO_TOKEN=$(curl -sf "${BAO_ADDR}/v1/auth/kubernetes/login" \ |
| 167 | + -d "{\"role\":\"external-secrets\",\"jwt\":\"${SA_JWT}\"}" \ |
| 168 | + | jq -r '.auth.client_token') |
| 169 | +
|
| 170 | + curl -sf "${BAO_ADDR}/v1/kv/data/apps/test/canary" \ |
| 171 | + -H "X-Vault-Token: ${BAO_TOKEN}" \ |
| 172 | + -d "{\"data\":{\"value\":\"${CANARY_VALUE}\"}}" |
| 173 | +
|
| 174 | + echo "Canary written: ${CANARY_VALUE}" |
| 175 | +
|
| 176 | + # ── Cluster destroy & recreate ───────────────────────────────────────── |
| 177 | + |
| 178 | + - name: Destroy minikube |
| 179 | + run: minikube delete |
| 180 | + |
| 181 | + - name: Recreate minikube |
| 182 | + uses: medyagh/setup-minikube@latest |
| 183 | + |
| 184 | + - name: Re-install ArgoCD |
| 185 | + run: | |
| 186 | + kubectl create namespace argocd |
| 187 | + kubectl apply -n argocd \ |
| 188 | + -f "https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml" |
| 189 | + kubectl rollout status deployment/argocd-server -n argocd --timeout=180s |
| 190 | +
|
| 191 | + - name: Re-expose ArgoCD + login |
| 192 | + run: | |
| 193 | + kubectl port-forward svc/argocd-server -n argocd 8080:443 & |
| 194 | + sleep 8 |
| 195 | + PASS=$(kubectl -n argocd get secret argocd-initial-admin-secret \ |
| 196 | + -o jsonpath="{.data.password}" | base64 -d) |
| 197 | + argocd login localhost:8080 --username admin --password "${PASS}" --insecure |
| 198 | + argocd repo add "${REPO_URL}" \ |
| 199 | + --username x-access-token \ |
| 200 | + --password "${{ secrets.GITHUB_TOKEN }}" \ |
| 201 | + --insecure-skip-server-verification || true |
| 202 | +
|
| 203 | + - name: Re-inject S3 credentials Secret |
| 204 | + run: | |
| 205 | + kubectl create namespace openbao --dry-run=client -o yaml | kubectl apply -f - |
| 206 | + kubectl create secret generic scaleway-s3-credentials \ |
| 207 | + --namespace openbao \ |
| 208 | + --from-literal=access_key="${{ secrets.SCW_ACCESS_KEY }}" \ |
| 209 | + --from-literal=secret_key="${{ secrets.SCW_SECRET_KEY }}" \ |
| 210 | + --from-literal=bucket="${{ vars.SCW_S3_BUCKET }}" |
| 211 | +
|
| 212 | + - name: Re-apply bootstrap Application |
| 213 | + run: | |
| 214 | + argocd app create bootstrap \ |
| 215 | + --repo "${REPO_URL}" \ |
| 216 | + --path bootstrap \ |
| 217 | + --dest-server https://kubernetes.default.svc \ |
| 218 | + --dest-namespace argocd \ |
| 219 | + --helm-set env=local \ |
| 220 | + --helm-set "revision=${BRANCH}" \ |
| 221 | + --helm-set "repoURL=${REPO_URL}" \ |
| 222 | + --sync-policy automated \ |
| 223 | + --upsert |
| 224 | +
|
| 225 | + - name: Wait for OpenBao to unseal after recreate |
| 226 | + id: wait-unseal-2 |
| 227 | + run: | |
| 228 | + for i in $(seq 1 72); do |
| 229 | + CIP=$(kubectl get svc openbao -n openbao -o jsonpath='{.spec.clusterIP}' 2>/dev/null || true) |
| 230 | + if [ -n "${CIP}" ]; then BAO_ADDR="http://${CIP}:8200"; fi |
| 231 | +
|
| 232 | + STATUS=$(curl -sf -o /dev/null -w "%{http_code}" \ |
| 233 | + "${BAO_ADDR}/v1/sys/health" 2>/dev/null || echo "000") |
| 234 | + echo "Attempt ${i}/72 — OpenBao status: ${STATUS}" |
| 235 | +
|
| 236 | + if [ "${STATUS}" = "200" ] || [ "${STATUS}" = "429" ]; then |
| 237 | + echo "OpenBao is unsealed after recreate." |
| 238 | + break |
| 239 | + fi |
| 240 | + sleep 5 |
| 241 | + done |
| 242 | +
|
| 243 | + if [ "${STATUS}" != "200" ] && [ "${STATUS}" != "429" ]; then |
| 244 | + echo "ERROR: OpenBao did not unseal after cluster recreate" |
| 245 | + kubectl get events -n openbao --sort-by='.lastTimestamp' | tail -20 || true |
| 246 | + exit 1 |
| 247 | + fi |
| 248 | +
|
| 249 | + echo "BAO_ADDR=${BAO_ADDR}" >> "${GITHUB_ENV}" |
| 250 | +
|
| 251 | + - name: Assert canary secret restored (SC-001) |
| 252 | + run: | |
| 253 | + SA_JWT=$(kubectl create token external-secrets -n external-secrets --duration=5m) |
| 254 | + BAO_TOKEN=$(curl -sf "${BAO_ADDR}/v1/auth/kubernetes/login" \ |
| 255 | + -d "{\"role\":\"external-secrets\",\"jwt\":\"${SA_JWT}\"}" \ |
| 256 | + | jq -r '.auth.client_token') |
| 257 | +
|
| 258 | + RESTORED=$(curl -sf "${BAO_ADDR}/v1/kv/data/apps/test/canary" \ |
| 259 | + -H "X-Vault-Token: ${BAO_TOKEN}" \ |
| 260 | + | jq -r '.data.data.value') |
| 261 | +
|
| 262 | + echo "Expected : ${CANARY_VALUE}" |
| 263 | + echo "Restored : ${RESTORED}" |
| 264 | +
|
| 265 | + if [ "${RESTORED}" != "${CANARY_VALUE}" ]; then |
| 266 | + echo "ERROR: Canary mismatch — secret not restored after destroy/recreate" |
| 267 | + exit 1 |
| 268 | + fi |
| 269 | + echo "OK: SC-001 verified — secrets survive cluster destroy/recreate" |
| 270 | +
|
| 271 | + - name: Assert no Infisical pods (SC-003) |
| 272 | + run: | |
| 273 | + if kubectl get pods -A -o name | grep -i infisical; then |
| 274 | + echo "ERROR: Infisical pods found in cluster" |
| 275 | + exit 1 |
| 276 | + fi |
| 277 | + echo "OK: No Infisical pods in cluster" |
0 commit comments