Turborepo + pnpm monorepo for k3s homelab cluster on Intel NUCs. - Apps: Next.js web frontend, Express API (TypeScript, Dockerfiles, k8s manifests) - Packages: shared UI, ESLint config, TypeScript config, Drizzle DB schemas - Infra/Ansible: bare-metal provisioning with roles for common, k3s-server, k3s-agent, hardening - Infra/Kubernetes: ArgoCD GitOps (app-of-apps + ApplicationSets), platform components (cert-manager, Traefik, CloudNativePG, Valkey, Longhorn, Sealed Secrets), namespaces - Observability: kube-prometheus-stack, Loki, Promtail as ArgoCD Applications - CI/CD: GitHub Actions for PR builds, preview deploys, production deploys - DX: Taskfile, utility scripts, copier templates, Ubiquiti network docs
60 lines
2.1 KiB
YAML
60 lines
2.1 KiB
YAML
name: Deploy Preview
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: pnpm
|
|
|
|
- run: pnpm install --frozen-lockfile
|
|
|
|
- name: Determine changed apps
|
|
id: changes
|
|
run: |
|
|
APPS=$(pnpm turbo build --filter='...[origin/main]' --dry-run=json | jq -r '[.packages[] | select(startswith("@homelab/")) | sub("@homelab/";"") ] | join(",")')
|
|
echo "apps=$APPS" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and push images
|
|
if: steps.changes.outputs.apps != ''
|
|
run: |
|
|
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
|
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
|
|
for app in "${APPS[@]}"; do
|
|
docker build \
|
|
-t ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }} \
|
|
apps/${app}
|
|
docker push ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }}
|
|
done
|
|
|
|
- name: Update image tags in preview overlay
|
|
if: steps.changes.outputs.apps != ''
|
|
run: |
|
|
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
|
|
for app in "${APPS[@]}"; do
|
|
cd apps/${app}/k8s/overlays/preview
|
|
kustomize edit set image ghcr.io/${{ github.repository_owner }}/homelab-${app}=ghcr.io/${{ github.repository_owner }}/homelab-${app}:${{ github.sha }}
|
|
cd -
|
|
done
|
|
|
|
- name: Comment preview URL
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: `## Preview Deploy\nNamespace: \`preview-${context.issue.number}\`\nArgoCD will sync automatically from branch \`${context.payload.pull_request.head.ref}\`.`
|
|
})
|