Files
homelab/.gitea/workflows/deploy-preview.yaml
Julia McGhee eb8e090283
Some checks failed
CI / changes (push) Successful in 5s
CI / lint-and-test (push) Successful in 23s
Deploy Production / deploy (push) Failing after 2m35s
CI / build (push) Has been skipped
Fix kustomize install: download binary, not apt package
kustomize isn't in Debian repos. Download from GitHub releases.
2026-03-21 16:36:06 +00:00

59 lines
2.3 KiB
YAML

name: Deploy Preview
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install tools
run: |
apt-get update && apt-get install -y jq curl
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv5.6.0/kustomize_v5.6.0_linux_amd64.tar.gz | tar xz -C /usr/local/bin
- run: corepack enable && corepack prepare pnpm@latest --activate
- 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 "${{ gitea.token }}" | docker login gitea.coreworlds.io -u ${{ gitea.actor }} --password-stdin
IFS=',' read -ra APPS <<< "${{ steps.changes.outputs.apps }}"
for app in "${APPS[@]}"; do
docker build \
-t gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }} \
apps/${app}
docker push gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.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 gitea.coreworlds.io/lazorgurl/homelab-${app}=gitea.coreworlds.io/lazorgurl/homelab-${app}:${{ gitea.sha }}
cd -
done
- name: Comment preview URL
env:
GITEA_TOKEN: ${{ gitea.token }}
run: |
curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"body\": \"## Preview Deploy\nNamespace: \`preview-${{ gitea.event.number }}\`\nArgoCD will sync automatically.\"}" \
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/${{ gitea.event.number }}/comments"