Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b388ff8e2 | ||
|
|
0d5f49591a | ||
|
|
12400b4c83 | ||
|
|
05bec1a5ff | ||
|
|
f6f74d9977 | ||
|
|
f2b8704914 | ||
|
|
be09d7592f | ||
|
|
abac1bf532 | ||
|
|
282e1c5236 | ||
|
|
339dcdd214 | ||
|
|
9b15ea5d33 | ||
|
|
344f748b84 | ||
|
|
84cf39e7d9 |
No files matched your search
@@ -0,0 +1,2 @@
|
||||
# Old Gitea token in deleted .env.local. Confirmed revoked (API returned 401) on 2026-11-22.
|
||||
8c69ec772ab5f0df73fa2614e5b8b22adb9bbd15:.env.local:gitea-access-token:2
|
||||
@@ -15,6 +15,10 @@
|
||||
# PATH path below /api/v1, e.g. /repos/kasun/homelab-infrastructure-as-code/pulls?state=open
|
||||
# BODY JSON string, or @file to send a file
|
||||
#
|
||||
# Read-only CI wait: gitea.sh WAIT /repos/OWNER/REPO/commits/SHA/status
|
||||
# Polls until checks finish. Exit 0: passed or no CI ran. 1: a check failed.
|
||||
# 2: bad usage. 3: timed out after 15 minutes.
|
||||
#
|
||||
# Config (outside the repo, never committed):
|
||||
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/url e.g. http://192.168.1.208:3000
|
||||
# ${XDG_CONFIG_HOME:-~/.config}/homelab-agent/token chmod 600
|
||||
@@ -28,6 +32,29 @@ method=${1:?usage: gitea.sh METHOD PATH [BODY]}
|
||||
path=${2:?usage: gitea.sh METHOD PATH [BODY]}
|
||||
body=${3:-}
|
||||
|
||||
if [[ "$method" == "WAIT" ]]; then
|
||||
[[ "$path" =~ ^/repos/[^/]+/[^/]+/commits/[0-9a-f]{40}/status$ ]] \
|
||||
|| { echo "WAIT only accepts /repos/OWNER/REPO/commits/SHA/status" >&2; exit 2; }
|
||||
for ((i = 1; i <= 45; i++)); do
|
||||
status=$("$0" GET "$path") || status='{}'
|
||||
total=$(jq '.statuses // [] | length' <<<"$status")
|
||||
running=$(jq '[.statuses // [] | .[] | select(.status == "pending" or .status == "running")] | length' <<<"$status")
|
||||
# Give checks time to register. Path-filtered workflows may never start any.
|
||||
if (( total == 0 && i >= 7 )); then
|
||||
echo "no CI ran"
|
||||
exit 0
|
||||
fi
|
||||
if (( total > 0 && running == 0 && i >= 4 )); then
|
||||
jq -r '.statuses[] | "\(.context): \(.status) \(.target_url)"' <<<"$status"
|
||||
jq -e '[.statuses[].status] | any(. == "failure" or . == "error") | not' <<<"$status" >/dev/null || exit 1
|
||||
exit 0
|
||||
fi
|
||||
sleep 20
|
||||
done
|
||||
echo "timed out waiting for CI" >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
case "$method" in
|
||||
GET | POST | PATCH | PUT | DELETE) ;;
|
||||
*) echo "unsupported method: $method" >&2; exit 2 ;;
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
"Bash(git add *)",
|
||||
"Bash(git switch *)",
|
||||
"Bash(.claude/scripts/gitea.sh GET *)",
|
||||
"Bash(.claude/scripts/gitea.sh WAIT *)",
|
||||
"Bash(.claude/scripts/gitea.sh POST *)",
|
||||
"Bash(git commit *)",
|
||||
"Bash(git push *)",
|
||||
|
||||
@@ -71,11 +71,11 @@ Unless one exists, run `.claude/scripts/gitea.sh POST $REPO/pulls @<json file>`
|
||||
|
||||
## 6. Wait for CI
|
||||
|
||||
Get the SHA with `git rev-parse HEAD`, then repeat `.claude/scripts/gitea.sh GET $REPO/commits/<sha>/status` until the state settles.
|
||||
Get the SHA with `git rev-parse HEAD`, then run `.claude/scripts/gitea.sh WAIT $REPO/commits/<sha>/status` as a background command. Do not write a polling loop, because that causes a permission prompt.
|
||||
|
||||
- `success`: continue.
|
||||
- `failure` or `error`: stop, and report the failing check and its `target_url`.
|
||||
- No statuses after about two minutes: workflows are path-filtered, so treat this as no CI for this PR and continue.
|
||||
- Exit 0: checks passed, or it printed `no CI ran` because workflows are path-filtered. Continue.
|
||||
- Exit 1: stop, and report the failing check and its `target_url`.
|
||||
- Exit 3: CI timed out. Stop and report it.
|
||||
|
||||
Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergeable` is true.
|
||||
|
||||
@@ -89,8 +89,8 @@ Then run `.claude/scripts/gitea.sh GET $REPO/pulls/<number>` and confirm `mergea
|
||||
Keep it short:
|
||||
|
||||
- PR link and commits.
|
||||
- What the merge deploys, from the `on.push.paths` in `.gitea/workflows/`. `03`, `04` and `05` deploy on merge, and a change under `.gitea/workflows/` can deploy all three.
|
||||
- For `01` or `02` changes, say that they are not live until someone runs the manual workflow.
|
||||
- What the merge deploys, from the `on.push.paths` in `.gitea/workflows/`. `01`, `03`, `04` and `05` deploy on merge. A change under `.gitea/workflows/` can deploy `03`, `04` and `05`, and a change to `01`'s own workflow deploys `01`.
|
||||
- For `02` changes, say that they are not live until someone runs the manual workflow.
|
||||
- Anything left uncommitted, and a reminder to update `<STACK>_PULUMI_DEV_YAML` if local Pulumi config changed.
|
||||
|
||||
Do not delete the branch, dispatch a workflow, or change a live system.
|
||||
@@ -3,6 +3,13 @@ name: Deploy Proxmox Infra
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "01-proxmox-infra/**"
|
||||
- ".gitea/workflows/01-deploy-proxmox-infra.yaml"
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
@@ -51,7 +58,7 @@ jobs:
|
||||
deploy:
|
||||
name: Pulumi Deploy
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
@@ -75,7 +82,10 @@ jobs:
|
||||
run: pulumi package add terraform-provider marshallford/pfsense 0.22.0
|
||||
working-directory: 01-proxmox-infra
|
||||
|
||||
# Manual runs only: a refresh that finds a VM missing drops it from state,
|
||||
# and `up` would then create a blank replacement without review.
|
||||
- name: Refresh State
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
run: |
|
||||
pulumi login "$PULUMI_BACKEND_URL"
|
||||
pulumi refresh --yes --stack dev \
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "03-k8s-infra/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/03-deploy-k8s-infra.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "04-k8s-apps/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/04-deploy-k8s-apps.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- "05-monitoring/**"
|
||||
- ".gitea/workflows/**"
|
||||
- ".gitea/workflows/05-deploy-monitoring.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Secret Scan
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
BETTERLEAKS_VERSION: "1.10.1"
|
||||
BETTERLEAKS_SHA256: c174b42d7aa60caf58c0c3e555c0e4bed01fe6b0d99a412bce777b5af4ce913e
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
name: Betterleaks
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Full History
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Betterleaks
|
||||
run: |
|
||||
curl -fsSL -o /tmp/betterleaks.tar.gz \
|
||||
"https://github.com/betterleaks/betterleaks/releases/download/v${BETTERLEAKS_VERSION}/betterleaks_${BETTERLEAKS_VERSION}_linux_x64.tar.gz"
|
||||
echo "${BETTERLEAKS_SHA256} /tmp/betterleaks.tar.gz" | sha256sum -c -
|
||||
tar -xzf /tmp/betterleaks.tar.gz -C /tmp betterleaks
|
||||
|
||||
- name: Scan Git History
|
||||
run: /tmp/betterleaks git . --redact --verbose --no-banner --no-color --log-opts="--all -m -p -U0"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git pre-commit hook: blocks a commit if its staged changes contain a secret.
|
||||
#
|
||||
# Activate once per clone: git config core.hooksPath .githooks
|
||||
# Skip in an emergency: git commit --no-verify
|
||||
if ! command -v betterleaks >/dev/null 2>&1; then
|
||||
echo "pre-commit: betterleaks is not installed, so staged changes can't be scanned" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec betterleaks git --pre-commit --staged --redact --no-banner --no-color .
|
||||
@@ -6,3 +6,5 @@ bin/
|
||||
Pulumi.dev.yaml
|
||||
sdks/
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
@@ -11,6 +11,7 @@ config:
|
||||
packages:
|
||||
pfsense:
|
||||
source: terraform-provider
|
||||
version: 1.1.3
|
||||
version: 1.5.1
|
||||
parameters:
|
||||
- marshallford/pfsense
|
||||
- 0.22.0
|
||||
@@ -141,7 +141,7 @@ const pveNodes = pveNodeSeeds
|
||||
},
|
||||
],
|
||||
},
|
||||
{ provider: n.provider, ignoreChanges: ["disks"] },
|
||||
{ provider: n.provider, protect: true, ignoreChanges: ["disks"] },
|
||||
),
|
||||
}));
|
||||
|
||||
@@ -291,7 +291,7 @@ const k3sVms = nodeConfigs.map(
|
||||
agent: { enabled: true, timeout: "30s" },
|
||||
cdrom: { fileId: "none" },
|
||||
started: false,
|
||||
stopOnDestroy: true,
|
||||
rebootAfterUpdate: false,
|
||||
},
|
||||
{
|
||||
provider: node.host.provider,
|
||||
@@ -322,7 +322,7 @@ k3sVms.forEach((vmResource, i) => {
|
||||
ipAddress: nodeConfigs[i].ip,
|
||||
hostname: nodeConfigs[i].name,
|
||||
},
|
||||
{ dependsOn: vmResource, provider: pfSenseProvider },
|
||||
{ dependsOn: vmResource, provider: pfSenseProvider, protect: true },
|
||||
);
|
||||
});
|
||||
|
||||
@@ -357,7 +357,7 @@ const ansibleDhcp = new pfsense.Dhcpv4Staticmapping(
|
||||
ipAddress: ansibleIp,
|
||||
hostname: "ansible",
|
||||
},
|
||||
{ provider: pfSenseProvider },
|
||||
{ provider: pfSenseProvider, protect: true },
|
||||
);
|
||||
|
||||
new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
||||
@@ -396,6 +396,7 @@ new proxmox.ContainerLegacy( // NOSONAR typescript:S1848
|
||||
provider: ansibleHost.provider,
|
||||
dependsOn: ansibleDhcp,
|
||||
retainOnDelete: true,
|
||||
protect: true,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Generated
+365
-1691
File diff suppressed because it is too large.
Load diff
@@ -26,7 +26,7 @@ proxmox-infra → k8s-bootstrap → k8s-infra
|
||||
- **Secrets**: read via `config.requireSecret()`, never via environment variables or hardcoded values.
|
||||
- **`Pulumi.dev.yaml`**: gitignored (contains the encryption salt). Never delete it or secrets become unrecoverable. CI restores it from a base64 Gitea secret `<STACK>_PULUMI_DEV_YAML`; after changing local config, remind me to update that secret.
|
||||
- **Environment**: `PULUMI_BACKEND_URL` (self-hosted Postgres backend) and `PULUMI_CONFIG_PASSPHRASE` must be set.
|
||||
- **CI**: PRs run `pulumi preview`. `03`–`05` deploy on push to `main`; `01`/`02` deploy only via manual dispatch.
|
||||
- **CI**: PRs run `pulumi preview`. `01` and `03`–`05` deploy on push to `main`; `02` deploys only via manual dispatch. Automatic `01` deploys skip `pulumi refresh`, so run its workflow manually after changing VMs in the Proxmox GUI.
|
||||
|
||||
## Git conventions
|
||||
|
||||
|
||||
+1
-1
@@ -60,4 +60,4 @@ This repo uses Gitea Actions (see root `CLAUDE.md`); Gitea's merge commit reuses
|
||||
- `Enhancement: Refactor k8s-bootstrap for clearer deployment order`
|
||||
- `Chore: Upgrade Pulumi packages across all stacks`
|
||||
|
||||
Since `01`/`02` deploys are manual (`workflow_dispatch`) and `03`–`05` deploy on merge to `main`, a clear PR title also doubles as a quick changelog of what just went live.
|
||||
Since `02` deploys are manual (`workflow_dispatch`) and `01` and `03`–`05` deploy on merge to `main`, a clear PR title also doubles as a quick changelog of what just went live.
|
||||
@@ -120,10 +120,11 @@ One workflow per stack, `.gitea/workflows/0N-deploy-<stack>.yaml`, scoped to cha
|
||||
| Trigger | Stacks | Action |
|
||||
| --- | --- | --- |
|
||||
| PR → `main` | all | `pulumi preview` (read-only) |
|
||||
| Push to `main` | 01 | `pulumi up` (no refresh) |
|
||||
| Push to `main` | 03–05 | `pulumi refresh` + `pulumi up` |
|
||||
| Manual dispatch | all | `pulumi refresh` + `pulumi up` |
|
||||
|
||||
Stacks 01/02 (VM provisioning, cluster bootstrap) deploy **only** via manual dispatch — they're riskier to automate.
|
||||
Stack 02 (cluster bootstrap) deploys **only** via manual dispatch, because re-running it restarts the bootstrap sequence. Stack 01 (VM provisioning) skips the refresh on automatic deploys so a VM missing from Proxmox can't be recreated blank. After changing VMs in the Proxmox GUI, run its workflow manually to sync state.
|
||||
|
||||
### Required secrets
|
||||
|
||||
|
||||
Reference in new issue
Block a user